summaryrefslogtreecommitdiff
path: root/src/bin/embryo
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-01 18:51:30 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-01 19:40:46 +0900
commit1b74f19b60ed46eb28b6e3469227fb733e00fb7a (patch)
treefe7e1af10002a00dbc8227994a0eba5c0621c0a1 /src/bin/embryo
parent6d694962c651da9c7e2b0a1fb3aa784b3b56ec9d (diff)
embryo_cc - fix buffer overrun possibility
fix CID 1039586
Diffstat (limited to 'src/bin/embryo')
-rw-r--r--src/bin/embryo/embryo_cc_sc2.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/bin/embryo/embryo_cc_sc2.c b/src/bin/embryo/embryo_cc_sc2.c
index b63354f821..2da0656c2a 100644
--- a/src/bin/embryo/embryo_cc_sc2.c
+++ b/src/bin/embryo/embryo_cc_sc2.c
@@ -2168,16 +2168,30 @@ needtoken(int token)
2168 { 2168 {
2169 /* token already pushed back */ 2169 /* token already pushed back */
2170 assert(_pushed); 2170 assert(_pushed);
2171 if (token < 256) 2171 if (token < 256)
2172 sprintf(s1, "%c", (char)token); /* single character token */ 2172 {
2173 else 2173 s1[0] = (char)token; /* single character token */
2174 strcpy(s1, sc_tokens[token - tFIRST]); /* multi-character symbol */ 2174 s1[1] = 0;
2175 if (!freading) 2175 }
2176 strcpy(s2, "-end of file-"); 2176 else
2177 else if (_lextok < 256) 2177 {
2178 sprintf(s2, "%c", (char)_lextok); 2178 strncpy(s1, sc_tokens[token - tFIRST], 19); /* multi-character symbol */
2179 else 2179 }
2180 strcpy(s2, sc_tokens[_lextok - tFIRST]); 2180 s1[19] = 0;
2181 if (!freading)
2182 {
2183 strncpy(s2, "-end of file-", 19);
2184 }
2185 else if (_lextok < 256)
2186 {
2187 s2[0] = (char)_lextok;
2188 s2[1] = 0;
2189 }
2190 else
2191 {
2192 strncpy(s2, sc_tokens[_lextok - tFIRST], 19);
2193 }
2194 s2[19] = 0;
2181 error(1, s1, s2); /* expected ..., but found ... */ 2195 error(1, s1, s2); /* expected ..., but found ... */
2182 return FALSE; 2196 return FALSE;
2183 } /* if */ 2197 } /* if */