various minor bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30470 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-05-29 06:42:38 +00:00
parent 2974accadd
commit d6ef02c19f
7 changed files with 25 additions and 19 deletions

View file

@ -1,3 +1,11 @@
2010-05-29 Richard Frith-Macdonald <rfm@gnu.org>
* NSConcreteHashTable.m:
* NSHashTable.m: In ([-allObjects]) fix buffer overrun (bug #29980).
* Source/NSXMLParser.m: Fix off-by-one error handling whitespace.
* Headers/Additions/GNUstepBase/GSMime.h: Revert xml charset method.
* Source/NSURL.m: Allow a URL made from an empty string (OSX compat).
2010-05-28 Quentin Mathe <quentin.mathe@gmail.com> 2010-05-28 Quentin Mathe <quentin.mathe@gmail.com>
* Source/NSKeyValueCoding.m: Added missing support to ValueForKey() as * Source/NSKeyValueCoding.m: Added missing support to ValueForKey() as

View file

@ -119,7 +119,6 @@ extern "C" {
#endif #endif
} }
+ (NSString*) charsetForXml: (NSData*)xml;
+ (NSString*) charsetFromEncoding: (NSStringEncoding)enc; + (NSString*) charsetFromEncoding: (NSStringEncoding)enc;
/** /**

View file

@ -3822,6 +3822,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
unsigned char *dst; unsigned char *dst;
unsigned char buf[4]; unsigned char buf[4];
NSUInteger pos = 0; NSUInteger pos = 0;
int pad = 0;
if (source == nil) if (source == nil)
{ {
@ -3870,6 +3871,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
else if (c == '=') else if (c == '=')
{ {
c = -1; c = -1;
pad++;
} }
else if (c == '-') else if (c == '-')
{ {
@ -3895,19 +3897,15 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (pos > 0) if (pos > 0)
{ {
NSUInteger i; NSUInteger i;
unsigned char tail[3];
for (i = pos; i < 4; i++) for (i = pos; i < 4; i++)
{ {
buf[i] = '\0'; buf[i] = '\0';
} }
pos--; decodebase64(tail, buf);
if (pos > 0) memcpy(dst, tail, 3 - pad);
{ dst += 3 - pad;
unsigned char tail[3];
decodebase64(tail, buf);
memcpy(dst, tail, pos);
dst += pos;
}
} }
return AUTORELEASE([[NSData allocWithZone: NSDefaultMallocZone()] return AUTORELEASE([[NSData allocWithZone: NSDefaultMallocZone()]
initWithBytesNoCopy: result length: dst - result]); initWithBytesNoCopy: result length: dst - result]);

View file

@ -861,12 +861,13 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
enumerator = NSEnumerateHashTable(self); enumerator = NSEnumerateHashTable(self);
index = 0; index = 0;
while ((objects[index] = NSNextHashEnumeratorItem(&enumerator)) != nil) while (index < nodeCount
&& (objects[index] = NSNextHashEnumeratorItem(&enumerator)) != nil)
{ {
index++; index++;
} }
NSEndHashTableEnumeration(&enumerator); NSEndHashTableEnumeration(&enumerator);
a = [[[NSArray alloc] initWithObjects: objects count: nodeCount] autorelease]; a = [[[NSArray alloc] initWithObjects: objects count: index] autorelease];
GS_ENDITEMBUF(); GS_ENDITEMBUF();
return a; return a;
} }

View file

@ -112,11 +112,11 @@ static Class concreteClass = 0;
enumerator = [self objectEnumerator]; enumerator = [self objectEnumerator];
index = 0; index = 0;
while ((objects[index] = [enumerator nextObject]) != nil) while (index < nodeCount && (objects[index] = [enumerator nextObject]) != nil)
{ {
index++; index++;
} }
a = [[[NSArray alloc] initWithObjects: objects count: nodeCount] autorelease]; a = [[[NSArray alloc] initWithObjects: objects count: index] autorelease];
GS_ENDITEMBUF(); GS_ENDITEMBUF();
return a; return a;
} }

View file

@ -662,6 +662,7 @@ static unsigned urlAlign;
* may be nil, but aUrlString must be non-nil.<br /> * may be nil, but aUrlString must be non-nil.<br />
* Accepts RFC2732 style IPv6 host addresses.<br /> * Accepts RFC2732 style IPv6 host addresses.<br />
* Parses a string wihthout a scheme as a simple path.<br /> * Parses a string wihthout a scheme as a simple path.<br />
* Parses an empty string as an empty path.<br />
* If the string cannot be parsed the method returns nil. * If the string cannot be parsed the method returns nil.
*/ */
- (id) initWithString: (NSString*)aUrlString - (id) initWithString: (NSString*)aUrlString
@ -685,11 +686,6 @@ static unsigned urlAlign;
format: @"[%@ %@] bad base URL parameter", format: @"[%@ %@] bad base URL parameter",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
} }
if ([aUrlString length] == 0)
{
DESTROY(self);
return nil;
}
ASSIGNCOPY(_urlString, aUrlString); ASSIGNCOPY(_urlString, aUrlString);
ASSIGN(_baseURL, [aBaseUrl absoluteURL]); ASSIGN(_baseURL, [aBaseUrl absoluteURL]);
NS_DURING NS_DURING

View file

@ -38,6 +38,10 @@
#import "GNUstepBase/NSObject+GNUstepBase.h" #import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GNUstepBase/GSMime.h" #import "GNUstepBase/GSMime.h"
@interface GSMimeDocument (internal)
+ (NSString*) charsetForXml: (NSData*)xml;
@end
NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain"; NSString* const NSXMLParserErrorDomain = @"NSXMLParserErrorDomain";
static NSNull *null = nil; static NSNull *null = nil;
@ -1357,7 +1361,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
foundIgnorableSel, self, s); foundIgnorableSel, self, s);
[s release]; [s release];
} }
vp = this->cp; vp = this->cp - 1;
} }
/* We have read non-space data, so whitespace is no longer /* We have read non-space data, so whitespace is no longer
* ignorable, and the buffer no loinger contains only space. * ignorable, and the buffer no loinger contains only space.