embryo_cc - fix possible buffer overrun
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Mon, 1 Sep 2014 10:15:46 +0000 (19:15 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Mon, 1 Sep 2014 10:40:47 +0000 (19:40 +0900)
fix CID 1039594

src/bin/embryo/embryo_cc_sc1.c

index ff998e7..0cf39e4 100644 (file)
@@ -1560,7 +1560,8 @@ decl_const(int vclass)
    if (lex(&val, &str) != tSYMBOL)     /* read in (new) token */
       error(20, str);          /* invalid symbol name */
    symbolline = fline;         /* save line where symbol was found */
-   strcpy(constname, str);     /* save symbol name */
+   strncpy(constname, str, sizeof(constname) - 1);     /* save symbol name */
+   constname[sizeof(constname) - 1] = 0;
    needtoken('=');
    constexpr(&val, &exprtag);  /* get value */
    needtoken(tTERM);