diff --git a/ChangeLog b/ChangeLog index 47d96eaf7..459418d09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-10-03 Fred Kiefer + + * Source/NSPropertyList.m (GSBinaryPLParser -objectAtIndex:): Use + long long for all integer types. Before we used signed types which + resulted wrong values for negative integers. + * Source/NSKeyedUnarchiver.m (-_decodeObject:): Handle the string + "$null" as nil all the times. + 2011-10-03 Richard Frith-Macdonald * Source/NSHost.m: Update to use inet_pton() and inet_ntop() and to diff --git a/Source/NSKeyedUnarchiver.m b/Source/NSKeyedUnarchiver.m index e5024795e..b5d5f712e 100644 --- a/Source/NSKeyedUnarchiver.m +++ b/Source/NSKeyedUnarchiver.m @@ -259,11 +259,12 @@ static NSMapTable *globalClassMap = 0; GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)obj, index); } - if (obj == nil) + if ((obj == nil) || [@"$null" isEqual: obj]) { // Record NilMarker for decoded object. o = GSIArrayItemAtIndex(_objMap, 0).obj; GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index); + obj = nil; } return obj; @@ -500,8 +501,8 @@ static NSMapTable *globalClassMap = 0; if (i > INT_MAX || i < INT_MIN) { [NSException raise: NSRangeException - format: @"[%@ +%@]: value for key(%@) is out of range", - NSStringFromClass([self class]), NSStringFromSelector(_cmd), aKey]; + format: @"[%@ +%@]: value %ld for key(%@) is out of range", + NSStringFromClass([self class]), NSStringFromSelector(_cmd), i, aKey]; } #endif return (int)i; diff --git a/Source/NSPropertyList.m b/Source/NSPropertyList.m index f77706d06..01882cc73 100644 --- a/Source/NSPropertyList.m +++ b/Source/NSPropertyList.m @@ -2998,28 +2998,18 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml, unsigned i; unsigned char buffer[16]; + if (len > sizeof(unsigned long long)) + { + [NSException raise: NSInvalidArgumentException + format: @"Stored number too long (%d bytes) in property list", len]; + } + [data getBytes: buffer range: NSMakeRange(counter, len)]; for (i = 0; i < len; i++) { num = (num << 8) + buffer[i]; } - - if (next == 0x10) - { - result = [NSNumber numberWithUnsignedChar: (unsigned char)num]; - } - else if (next == 0x11) - { - result = [NSNumber numberWithUnsignedShort: (unsigned short)num]; - } - else if ((next == 0x12) || (next == 13)) - { - result = [NSNumber numberWithUnsignedInt: (unsigned int)num]; - } - else - { - result = [NSNumber numberWithUnsignedLongLong: num]; - } + result = [NSNumber numberWithLongLong: (long long)num]; } else if (next == 0x22) {