Fix crsh when trimming space containing unicode character with high byte non zero.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20196 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-10-05 08:32:18 +00:00
parent 560e7abd15
commit f349c02156
2 changed files with 14 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2004-10-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSGategories.m: make whitespace test safe for
unicode characters.
2004-10-04 Richard Frith-Macdonald <rfm@gnu.org> 2004-10-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSHTTPURLHandle.m: Fix premature end of read where no * Source/GSHTTPURLHandle.m: Fix premature end of read where no

View file

@ -27,6 +27,9 @@
#include "GNUstepBase/GSCategories.h" #include "GNUstepBase/GSCategories.h"
#include "GNUstepBase/GSLock.h" #include "GNUstepBase/GSLock.h"
/* Test for ASCII whitespace which is safe for unicode characters */
#define space(C) ((C) > 127 ? NO : isspace(C))
/** /**
* Extension methods for the NSCalendarDate class * Extension methods for the NSCalendarDate class
*/ */
@ -912,7 +915,7 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
SEL caiSel = @selector(characterAtIndex:); SEL caiSel = @selector(characterAtIndex:);
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
while (start < length && isspace((*caiImp)(self, caiSel, start))) while (start < length && space((*caiImp)(self, caiSel, start)))
{ {
start++; start++;
} }
@ -941,7 +944,7 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
while (end > 0) while (end > 0)
{ {
if (!isspace((*caiImp)(self, caiSel, end - 1))) if (!space((*caiImp)(self, caiSel, end - 1)))
{ {
break; break;
} }
@ -971,13 +974,13 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
SEL caiSel = @selector(characterAtIndex:); SEL caiSel = @selector(characterAtIndex:);
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
while (start < length && isspace((*caiImp)(self, caiSel, start))) while (start < length && space((*caiImp)(self, caiSel, start)))
{ {
start++; start++;
} }
while (end > start) while (end > start)
{ {
if (!isspace((*caiImp)(self, caiSel, end - 1))) if (!space((*caiImp)(self, caiSel, end - 1)))
{ {
break; break;
} }
@ -1087,7 +1090,7 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
SEL caiSel = @selector(characterAtIndex:); SEL caiSel = @selector(characterAtIndex:);
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
while (start < length && isspace((*caiImp)(self, caiSel, start))) while (start < length && space((*caiImp)(self, caiSel, start)))
{ {
start++; start++;
} }
@ -1112,7 +1115,7 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
SEL caiSel = @selector(characterAtIndex:); SEL caiSel = @selector(characterAtIndex:);
caiImp = (unichar (*)())[self methodForSelector: caiSel]; caiImp = (unichar (*)())[self methodForSelector: caiSel];
while (end > 0 && isspace((*caiImp)(self, caiSel, end - 1))) while (end > 0 && space((*caiImp)(self, caiSel, end - 1)))
{ {
end--; end--;
} }