part1 of fixing #6599:

* protect against invocations of ctype-macros/-functions with negative
  character indices by mirroring the corresponding values at negative
  array indices (the legal access range of __ctype_b is now [-128..255])


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38708 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2010-09-18 15:55:42 +00:00
parent 4a0b7d1bd0
commit 6a5dacaa3c
5 changed files with 105 additions and 41 deletions
+10 -6
View File
@@ -33,13 +33,17 @@ public:
private:
/*
* the following arrays have 257 elements where the first is a
* dummy element (containing the neutral/identity value) used when
* the array is accessed as in 'isblank(EOF)' (i.e. with index -1).
* The following arrays have 384 elements where the elements at
* index -128..-2 mirror the elements at index 128..255 (to protect
* against invocations of ctype macros with negative character
* values).
* The element at index -1 is a dummy element containing the
* neutral/identity value used when the array is accessed as in
* 'isblank(EOF)' (i.e. with index -1).
*/
unsigned short fClassInfo[257];
int fToLowerMap[257];
int fToUpperMap[257];
unsigned short fClassInfo[384];
int fToLowerMap[384];
int fToUpperMap[384];
LocaleCtypeDataBridge* fDataBridge;
};
+9 -6
View File
@@ -10,13 +10,16 @@ namespace BPrivate {
/*
* the following arrays have 257 elements where the first is a
* dummy element (containing the neutral/identity value) used when
* the array is accessed as in 'isblank(EOF)' (i.e. with index -1).
* The following arrays have 384 elements where the elements at index -128..-2
* mirror the elements at index 128..255 (to protect against invocations of
* ctype macros with negative character values).
* The element at index -1 is a dummy element containing the neutral/identity
* value used when the array is accessed as in 'isblank(EOF)' (i.e. with
* index -1).
*/
extern const unsigned short gPosixClassInfo[257];
extern const int gPosixToLowerMap[257];
extern const int gPosixToUpperMap[257];
extern const unsigned short gPosixClassInfo[384];
extern const int gPosixToLowerMap[384];
extern const int gPosixToUpperMap[384];
} // namespace BPrivate