Fix another case of out-of-bounds access of gLexTable. b=233399 r+sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2004-02-08 19:22:47 +00:00
Родитель 02ed7b40de
Коммит 456b60e585
2 изменённых файлов: 20 добавлений и 24 удалений

Просмотреть файл

@ -689,7 +689,10 @@ PRInt32 nsCSSScanner::ParseEscape(nsresult& aErrorCode)
// Whoops: error or premature eof
break;
}
if ((lexTable[ch] & IS_HEX_DIGIT) != 0) {
if (ch >= 256 || (lexTable[ch] & (IS_HEX_DIGIT | IS_WHITESPACE)) == 0) {
Unread();
break;
} else if ((lexTable[ch] & IS_HEX_DIGIT) != 0) {
if ((lexTable[ch] & IS_DIGIT) != 0) {
rv = rv * 16 + (ch - '0');
} else {
@ -698,20 +701,15 @@ PRInt32 nsCSSScanner::ParseEscape(nsresult& aErrorCode)
// "relative to 10" value for computing the hex value.
rv = rv * 16 + ((ch & 0x7) + 9);
}
}
else if ((lexTable[ch] & IS_WHITESPACE) != 0) { // single space ends escape
if (ch == '\r') { // if CR/LF, eat LF too
ch = Peek(aErrorCode);
if (ch == '\n') {
ch = Read(aErrorCode);
}
} else {
NS_ASSERTION((lexTable[ch] & IS_WHITESPACE) != 0, "bad control flow");
// single space ends escape
if (ch == '\r' && Peek(aErrorCode) == '\n') {
// if CR/LF, eat LF too
Read(aErrorCode);
}
break;
}
else {
Unread();
break;
}
}
if (6 == i) { // look for trailing whitespace and eat it
ch = Peek(aErrorCode);

Просмотреть файл

@ -689,7 +689,10 @@ PRInt32 nsCSSScanner::ParseEscape(nsresult& aErrorCode)
// Whoops: error or premature eof
break;
}
if ((lexTable[ch] & IS_HEX_DIGIT) != 0) {
if (ch >= 256 || (lexTable[ch] & (IS_HEX_DIGIT | IS_WHITESPACE)) == 0) {
Unread();
break;
} else if ((lexTable[ch] & IS_HEX_DIGIT) != 0) {
if ((lexTable[ch] & IS_DIGIT) != 0) {
rv = rv * 16 + (ch - '0');
} else {
@ -698,20 +701,15 @@ PRInt32 nsCSSScanner::ParseEscape(nsresult& aErrorCode)
// "relative to 10" value for computing the hex value.
rv = rv * 16 + ((ch & 0x7) + 9);
}
}
else if ((lexTable[ch] & IS_WHITESPACE) != 0) { // single space ends escape
if (ch == '\r') { // if CR/LF, eat LF too
ch = Peek(aErrorCode);
if (ch == '\n') {
ch = Read(aErrorCode);
}
} else {
NS_ASSERTION((lexTable[ch] & IS_WHITESPACE) != 0, "bad control flow");
// single space ends escape
if (ch == '\r' && Peek(aErrorCode) == '\n') {
// if CR/LF, eat LF too
Read(aErrorCode);
}
break;
}
else {
Unread();
break;
}
}
if (6 == i) { // look for trailing whitespace and eat it
ch = Peek(aErrorCode);