RESOLVED FIXED 31451
LocalStorage quota should include key sizes in its count
https://bugs.webkit.org/show_bug.cgi?id=31451
Summary LocalStorage quota should include key sizes in its count
Jeremy Orlow
Reported 2009-11-12 18:59:34 PST
LocalStorage quota should include key sizes in its count.
Attachments
Patch (5.82 KB, patch)
2009-11-12 19:03 PST, Jeremy Orlow
no flags
Patch (5.98 KB, patch)
2009-11-12 20:20 PST, Jeremy Orlow
no flags
Patch (6.15 KB, patch)
2009-11-13 11:38 PST, Jeremy Orlow
dimich: review+
Jeremy Orlow
Comment 1 2009-11-12 19:03:21 PST
Dmitry Titov
Comment 2 2009-11-12 19:40:15 PST
Comment on attachment 43126 [details] Patch > + bool overflow = (newLength > m_currentLength) != (value.length() + keyLength > oldValue.length()); > + ASSERT(!overflow); // Make a fuss if we're debugging. But even if we aren't, don't allow overflow. If value.length() + keyLength overflows by itself, then this check might not detect the overflow. It seems the two-step method of detection as in StorageMap::importItem would work better.
Jeremy Orlow
Comment 3 2009-11-12 20:20:00 PST
Jeremy Orlow
Comment 4 2009-11-12 20:21:20 PST
If you have any ideas on how to simplify the logic, please let me know. It seems like it should be possible, but I didn't see any good ways. (Overflow sucks....) I could just make everything long longs and assume it's not possible. :-)
Dmitry Titov
Comment 5 2009-11-12 21:32:23 PST
Comment on attachment 43129 [details] Patch > + unsigned adjustedKeyLength = oldValue.isNull() ? key.length() : 0; > + newLength += adjustedKeyLength; > + overflow |= (newLength > m_currentLength) != (value.length() + adjustedKeyLength > oldValue.length()); I think the last line could be simply: overflow |= newLength < m_currentLength; r=me
Jeremy Orlow
Comment 6 2009-11-13 11:38:16 PST
Jeremy Orlow
Comment 7 2009-11-13 11:40:41 PST
Dmitry: What you posted won't quite work. overflow |= newLength + adjustedKeyLength < newLength would work. That gave me an idea on how to simplify the whole thing, though. So I re-did it with only making one adjustment at a time which greatly simplified the logic. Take another look?
Dmitry Titov
Comment 8 2009-11-13 12:01:48 PST
Comment on attachment 43173 [details] Patch Awesome! r=me
Jeremy Orlow
Comment 9 2009-11-13 16:27:46 PST
Note You need to log in before you can comment on or make changes to this bug.