From 67e7904ae54965bef26f0e22d0ea72022844e83e Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Sat, 21 Feb 2004 00:49:43 +0000 Subject: [PATCH] Extension for binary property lists to load bigger lists. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18635 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSPropertyList.m | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 795ee7ea2..1e50531b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-02-21 Fred Kiefer + + * Source/NSPropertyList.m: (GSBinaryPLParser + -initWithData:mutability:, -offsetForIndex:, -readObjectIndexAt:) + Added support for binary pls with size == 3. + 2004-02-19 Richard Frith-Macdonald * Source/Additions/GSMime.m: added a couple of uuencoding methods. diff --git a/Source/NSPropertyList.m b/Source/NSPropertyList.m index 1e9f01d27..887aa021a 100644 --- a/Source/NSPropertyList.m +++ b/Source/NSPropertyList.m @@ -2301,11 +2301,14 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, // FIXME: Get more of the details [plData getBytes: postfix range: NSMakeRange(length-32, 32)]; size = postfix[6]; - if (size < 1 || size > 2) + table_start = 256*256*postfix[29] + 256*postfix[30] + postfix[31]; + if (size < 1 || size > 3) { + [NSException raise: NSGenericException + format: @"Unknown table size %d", size]; DESTROY(self); // Bad format } - else if ((table_start = 256*postfix[30] + postfix[31]) > length - 32) + else if (table_start > length - 32) { DESTROY(self); // Bad format } @@ -2347,8 +2350,16 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, } else { - [NSException raise: NSGenericException - format: @"Unknown table size %d", size]; + unsigned char buffer[size]; + int i; + unsigned num = 0; + + [data getBytes: &buffer range: NSMakeRange(table_start + size*index, size)]; + for (i = 0; i < size; i++) + { + num = num*256 + buffer[i]; + } + return num; } return 0; } @@ -2363,7 +2374,7 @@ OAppend(id obj, NSDictionary *loc, unsigned lev, unsigned step, *counter += 1; return oid; } - else if (size == 2) + else if ((size == 2) || (size == 3)) { unsigned short oid;