diff options
author | ache <ache@FreeBSD.org> | 2001-11-28 09:50:24 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-11-28 09:50:24 +0000 |
commit | d415ec9a10e759b54f2c0c24c5b5889a91c4a365 (patch) | |
tree | aaefe61b87021bdb46c286d2659e0f25823480c8 /usr.bin/colldef/scan.l | |
parent | 1ab3b395034b90f9494aef83eb785a7f9c6a5cf1 (diff) | |
download | FreeBSD-src-d415ec9a10e759b54f2c0c24c5b5889a91c4a365.zip FreeBSD-src-d415ec9a10e759b54f2c0c24c5b5889a91c4a365.tar.gz |
Rewrite buffer handling code a bit to handle large values.
Add more checks for data overflow.
Diffstat (limited to 'usr.bin/colldef/scan.l')
-rw-r--r-- | usr.bin/colldef/scan.l | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/colldef/scan.l b/usr.bin/colldef/scan.l index ff24cd2..8085440 100644 --- a/usr.bin/colldef/scan.l +++ b/usr.bin/colldef/scan.l @@ -39,7 +39,7 @@ #include "y.tab.h" int line_no = 1, save_no, fromsubs; -u_char buf[80], *ptr; +u_char buf[BUFSIZE], *ptr; FILE *map_fp; YY_BUFFER_STATE main_buf, map_buf; #ifdef FLEX_DEBUG @@ -100,7 +100,7 @@ YYSTYPE yylval; yylval.ch = *yytext; return CHAR; } - if(yyleng > STR_LEN - 1) + if(yyleng > BUFSIZE - 1) errx(EX_UNAVAILABLE, "chain buffer overflow near line %u", line_no); strcpy(yylval.str, yytext); @@ -145,12 +145,13 @@ YYSTYPE yylval; errx(EX_UNAVAILABLE, "non-empty name expected near line %u", line_no); *ptr = '\0'; - for (i = 0; i <= UCHAR_MAX; i++) + for (i = 0; i <= UCHAR_MAX; i++) { if (strcmp(charmap_table[i], buf) == 0) goto findit; + } errx(EX_UNAVAILABLE, "name <%s> not 'charmap'-defined near line %u", buf, line_no); - findit: + findit: yylval.ch = i; if (fromsubs) BEGIN(subs); |