OSDN Git Service

DO NOT MERGE Use unsigned length when reading data
authorRussell Brenner <russellbrenner@google.com>
Tue, 29 Nov 2011 23:34:08 +0000 (15:34 -0800)
committerRussell Brenner <russellbrenner@google.com>
Wed, 30 Nov 2011 20:05:20 +0000 (12:05 -0800)
With a signed length, invalid negative sizes can bypass data limit
checks of the type:

        if (data + length < end)

With an unsigned length, absurdly large lengths will now trigger an
early exit instead of following through into the decoding routine
with a bad length.

Bug: 5143832
Change-Id: I8e4a8d357ee04a36e35ab47d538ce57088734ccf

Source/WebKit/android/jni/WebHistory.cpp

index 7ec73a3..aa74b81 100644 (file)
@@ -490,7 +490,7 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
 
     // Read the original url
     // Read the expected length of the string.
-    int l;
+    unsigned l;
     memcpy(&l, data, sizeofUnsigned);
     // Increment data pointer by the size of an unsigned int.
     data += sizeofUnsigned;