[ANGLE] Infinite loops and buffer overflow in byte_scan
- Fixed in 2 months
- Paid in 2.8 years
- Disclosed after 2 months
313 static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
318 int len, ch, ii, ival = 0;
320 for (;;) {
331 len = 0;
332 switch (ch) {
333 default:
334 return ch; // Single character token
335 case EOF:
336 return -1;
337 case 'A': case 'B': case 'C': case 'D': case 'E':
366 return CPP_IDENTIFIER;
this is useless:
367 break;
368 case '0':
369 yylvalpp->symbol_name[len++] = ch;
370 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
371 if (ch == 'x' || ch == 'X') {
372 yylvalpp->symbol_name[len++] = ch;
373 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
374 if ((ch >= '0' && ch <= '9') ||
375 (ch >= 'A' && ch <= 'F') ||
376 (ch >= 'a' && ch <= 'f'))
377 {
380 do {
nothing here seems to enforce a limit on len v. yylvalpp->symbol_name[]:
381 yylvalpp->symbol_name[len++] = ch;
Is it on the wrong side of do { ?
396 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
397 } while ((ch >= '0' && ch <= '9') ||
398 (ch >= 'A' && ch <= 'F') ||
399 (ch >= 'a' && ch <= 'f'));
400 } else {
402 }
403 yylvalpp->symbol_name[len] = '\0';
404 cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
406 return CPP_INTCONSTANT;
407 } else if (ch >= '0' && ch <= '7') { // octal integer constants
410 do {
nothing here seems to enforce a limit on len v. yylvalpp->symbol_name[]:
411 yylvalpp->symbol_name[len++] = ch;
Is it on the wrong side of do { ?
420 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
421 } while (ch >= '0' && ch <= '7');
424 yylvalpp->symbol_name[len] = '\0';
427 return CPP_INTCONSTANT;
428 } else {
429 cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
430 ch = '0';
431 }
432 // Fall through...
433 case '1': case '2': case '3': case '4':
434 case '5': case '6': case '7': case '8': case '9':
435 do {
This could result in an infinite loop if there's a string long enough to get len == MAX_SYMBOL_LEN (512). The code should probably break if that happens...
436 if (len < MAX_SYMBOL_NAME_LEN) {
I'm not sure why this is comparing len against 0, shouldn't that not be needed?
437 if (len > 0 || ch != '0') {
438 yylvalpp->symbol_name[len] = ch;
439 len++;
440 }
441 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
442 }
443 } while (ch >= '0' && ch <= '9');
444 if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {
445 return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
446 } else {
463 return CPP_INTCONSTANT;
464 }
this isn't reachable:
465 break;
466 case '-':
476 case '+':
486 case '*':
494 case '%':
504 case ':':
512 case '^':
525 case '=':
533 case '!':
541 case '|':
553 case '&':
565 case '<':
589 case '>':
607 case '.':
617 return '.';
620 case '/':
621 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
622 if (ch == '/') {
628 return '\n';
629 } else if (ch == '*') {
631 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
650 // Go try it again...
651 } else if (ch == '=') {
652 return CPP_DIV_ASSIGN;
653 } else {
655 return '/';
656 }
657 break;
658 case '"':
659 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
660 while (ch != '"' && ch != '\n' && ch != EOF) {
661 if (ch == '\\') {
663 return -1;
664 }
This could result in an infinite loop if there's a string long enough to get len == MAX_SYMBOL_LEN (512). The code should probably break if that happens...
665 if (len < MAX_STRING_LEN) {
666 string_val[len] = ch;
667 len++;
668 ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
669 }
670 };
674 return CPP_STRCONSTANT;
681 } // byte_scan
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A memory corruption bug in Graphics: CanvasWebGL. Mozilla made it public on 12 December 2010.
About Memory corruption
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.