summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-10-27 22:07:36 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-10-28 10:54:51 +0900
commite550b37453f6f948566e8f8ec7ce97bba70546d2 (patch)
treeec205ba3658ba7b9421489bc5b64496a91945bd2 /src/bin
parent8e4dafcf286af5de7af01cb7f7be0d1b6a8980f7 (diff)
Embryo: Use strncpy instead of strcpy in a few places
There are still lots of unsafe uses of strcpy, strcat, etc... Dunno if they are relevant though. Also, assert() may be compiled out at build time (release mode) so don't rely on it for safety. Fixes CID 1039593
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/embryo/embryo_cc_sc1.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/bin/embryo/embryo_cc_sc1.c b/src/bin/embryo/embryo_cc_sc1.c
index 0cf39e44bd..30a5329de8 100644
--- a/src/bin/embryo/embryo_cc_sc1.c
+++ b/src/bin/embryo/embryo_cc_sc1.c
@@ -1033,7 +1033,8 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
1033 if (firstname) 1033 if (firstname)
1034 { 1034 {
1035 assert(strlen(firstname) <= sNAMEMAX); 1035 assert(strlen(firstname) <= sNAMEMAX);
1036 strcpy(name, firstname); /* save symbol name */ 1036 strncpy(name, firstname, sNAMEMAX); /* save symbol name */
1037 name[sNAMEMAX] = 0;
1037 tag = firsttag; 1038 tag = firsttag;
1038 firstname = NULL; 1039 firstname = NULL;
1039 } 1040 }
@@ -1043,7 +1044,8 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
1043 if (lex(&val, &str) != tSYMBOL) /* read in (new) token */ 1044 if (lex(&val, &str) != tSYMBOL) /* read in (new) token */
1044 error(20, str); /* invalid symbol name */ 1045 error(20, str); /* invalid symbol name */
1045 assert(strlen(str) <= sNAMEMAX); 1046 assert(strlen(str) <= sNAMEMAX);
1046 strcpy(name, str); /* save symbol name */ 1047 strncpy(name, str, sNAMEMAX); /* save symbol name */
1048 name[sNAMEMAX] = 0;
1047 } /* if */ 1049 } /* if */
1048 sym = findglb(name); 1050 sym = findglb(name);
1049 if (!sym) 1051 if (!sym)
@@ -1181,7 +1183,8 @@ declloc(int fstatic)
1181 if (lex(&val, &str) != tSYMBOL) /* read in (new) token */ 1183 if (lex(&val, &str) != tSYMBOL) /* read in (new) token */
1182 error(20, str); /* invalid symbol name */ 1184 error(20, str); /* invalid symbol name */
1183 assert(strlen(str) <= sNAMEMAX); 1185 assert(strlen(str) <= sNAMEMAX);
1184 strcpy(name, str); /* save symbol name */ 1186 strncpy(name, str, sNAMEMAX); /* save symbol name */
1187 name[sNAMEMAX] = 0;
1185 if (name[0] == PUBLIC_CHAR) 1188 if (name[0] == PUBLIC_CHAR)
1186 error(56, name); /* local variables cannot be public */ 1189 error(56, name); /* local variables cannot be public */
1187 /* Note: block locals may be named identical to locals at higher 1190 /* Note: block locals may be named identical to locals at higher
@@ -1657,7 +1660,8 @@ decl_enum(int vclass)
1657 tok = lex(&lexval, &str); /* read in (new) token */ 1660 tok = lex(&lexval, &str); /* read in (new) token */
1658 if (tok != tSYMBOL && tok != tLABEL) 1661 if (tok != tSYMBOL && tok != tLABEL)
1659 error(20, str); /* invalid symbol name */ 1662 error(20, str); /* invalid symbol name */
1660 strcpy(constname, str); /* save symbol name */ 1663 strncpy(constname, str, sNAMEMAX); /* save symbol name */
1664 constname[sNAMEMAX] = 0;
1661 size = increment; /* default increment of 'val' */ 1665 size = increment; /* default increment of 'val' */
1662 if (tok == tLABEL || matchtoken(':')) 1666 if (tok == tLABEL || matchtoken(':'))
1663 constexpr(&size, NULL); /* get size */ 1667 constexpr(&size, NULL); /* get size */