comparison eval.c @ 203:3a25180d3a5c

Abort on line numbering or column numbering overflow. Line numbers are limited to values that fit in "unsigned int". Also reject input lines longer than 2^32-1 characters. It seems reasonable to presume that any input that violates these constraints is someone screwing around and not a serious attempt to compile or preprocess anything useful. Done in response to n2129, but without getting into any of the silliness found there.
author David A. Holland
date Tue, 01 Aug 2017 14:51:04 -0400
parents 1d2bad7151f9
children
comparison
equal deleted inserted replaced
202:e200cb46ab23 203:3a25180d3a5c
706 706
707 pos = 0; 707 pos = 0;
708 while (expr[pos] != '\0') { 708 while (expr[pos] != '\0') {
709 len = strspn(expr+pos, ws); 709 len = strspn(expr+pos, ws);
710 pos += len; 710 pos += len;
711 p->column += len; 711 place_addcolumns(p, len);
712 /* trailing whitespace is supposed to have been pruned */ 712 /* trailing whitespace is supposed to have been pruned */
713 assert(expr[pos] != '\0'); 713 assert(expr[pos] != '\0');
714 if (check_word(p, expr, pos, &len)) { 714 if (check_word(p, expr, pos, &len)) {
715 pos += len; 715 pos += len;
716 p->column += len; 716 place_addcolumns(p, len);
717 continue; 717 continue;
718 } 718 }
719 if (check_tokens_2(p, expr, pos)) { 719 if (check_tokens_2(p, expr, pos)) {
720 pos += 2; 720 pos += 2;
721 p->column += 2; 721 place_addcolumns(p, 2);
722 continue; 722 continue;
723 } 723 }
724 if (check_tokens_1(p, expr, pos)) { 724 if (check_tokens_1(p, expr, pos)) {
725 pos++; 725 pos++;
726 p->column++; 726 place_addcolumns(p, 1);
727 continue; 727 continue;
728 } 728 }
729 complain(p, "Invalid character %u in #if-expression", 729 complain(p, "Invalid character %u in #if-expression",
730 (unsigned char)expr[pos]); 730 (unsigned char)expr[pos]);
731 complain_fail(); 731 complain_fail();
732 pos++; 732 pos++;
733 p->column++; 733 place_addcolumns(p, 1);
734 } 734 }
735 token(p, T_EOF, 0); 735 token(p, T_EOF, 0);
736 } 736 }
737 737
738 bool 738 bool