aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-02-25 13:23:56 +0100
committerChristoph Lohmann <20h@r-36.net>2013-02-25 13:23:56 +0100
commit37863356b00cd41c24e10243121649473b98824f (patch)
tree44268518a1b4f425487aff918d0d68f900806d7c
parentbe7c6d7fb09ff50127332060d771b94a3bc8e44c (diff)
downloadst-patched-37863356b00cd41c24e10243121649473b98824f.tar.bz2
st-patched-37863356b00cd41c24e10243121649473b98824f.tar.xz
st-patched-37863356b00cd41c24e10243121649473b98824f.zip
Using strtol with overflow checking.
-rw-r--r--st.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/st.c b/st.c
index afa6813..23c4caf 100644
--- a/st.c
+++ b/st.c
@@ -1296,17 +1296,22 @@ tnewline(int first_col) {
1296void 1296void
1297csiparse(void) { 1297csiparse(void) {
1298 /* int noarg = 1; */ 1298 /* int noarg = 1; */
1299 char *p = csiescseq.buf; 1299 char *p = csiescseq.buf, *np;
1300 long int v;
1300 1301
1301 csiescseq.narg = 0; 1302 csiescseq.narg = 0;
1302 if(*p == '?') 1303 if(*p == '?')
1303 csiescseq.priv = 1, p++; 1304 csiescseq.priv = 1, p++;
1304 1305
1305 while(p < csiescseq.buf+csiescseq.len) { 1306 while(p < csiescseq.buf+csiescseq.len) {
1306 while(isdigit(*p)) { 1307 np = NULL;
1307 csiescseq.arg[csiescseq.narg] *= 10; 1308 v = strtol(p, &np, 10);
1308 csiescseq.arg[csiescseq.narg] += *p++ - '0'/*, noarg = 0 */; 1309 if(v == LONG_MAX || v == LONG_MIN)
1309 } 1310 v = -1;
1311 csiescseq.arg[csiescseq.narg] = v;
1312 if(np != NULL)
1313 p = np;
1314
1310 if(*p == ';' && csiescseq.narg+1 < ESC_ARG_SIZ) { 1315 if(*p == ';' && csiescseq.narg+1 < ESC_ARG_SIZ) {
1311 csiescseq.narg++, p++; 1316 csiescseq.narg++, p++;
1312 } else { 1317 } else {
@@ -2116,7 +2121,8 @@ tputc(char *c, int len) {
2116 if(BETWEEN(ascii, 0x40, 0x7E) 2121 if(BETWEEN(ascii, 0x40, 0x7E)
2117 || csiescseq.len >= ESC_BUF_SIZ) { 2122 || csiescseq.len >= ESC_BUF_SIZ) {
2118 term.esc = 0; 2123 term.esc = 0;
2119 csiparse(), csihandle(); 2124 csiparse();
2125 csihandle();
2120 } 2126 }
2121 } else if(term.esc & ESC_STR_END) { 2127 } else if(term.esc & ESC_STR_END) {
2122 term.esc = 0; 2128 term.esc = 0;