Avoid user induced buffer overflows.
Check against NULL pointer.
This commit is contained in:
parent
200cff4bdc
commit
c179b01734
|
|
@ -1107,8 +1107,14 @@ INPparseNode *PT_mkfnode(const char *fname, INPparseNode * arg)
|
||||||
INPparseNode *p;
|
INPparseNode *p;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
|
if (!fname) {
|
||||||
|
fprintf(stderr, "Error: bogus function name \n");
|
||||||
|
return mkfirst(NULL, arg);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the case is ok. */
|
/* Make sure the case is ok. */
|
||||||
(void) strcpy(buf, fname);
|
(void)strncpy(buf, fname, 127);
|
||||||
|
buf[127] = 0;
|
||||||
strtolower(buf);
|
strtolower(buf);
|
||||||
|
|
||||||
if(!strcmp("ternary_fcn", buf)) {
|
if(!strcmp("ternary_fcn", buf)) {
|
||||||
|
|
@ -1142,7 +1148,6 @@ INPparseNode *PT_mkfnode(const char *fname, INPparseNode * arg)
|
||||||
fprintf(stderr, "Error: no such function '%s'\n", buf);
|
fprintf(stderr, "Error: no such function '%s'\n", buf);
|
||||||
if (ft_stricterror)
|
if (ft_stricterror)
|
||||||
controlled_exit(EXIT_BAD);
|
controlled_exit(EXIT_BAD);
|
||||||
|
|
||||||
return mkfirst(NULL, arg);
|
return mkfirst(NULL, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1250,7 +1255,8 @@ INPparseNode *PT_mksnode(const char *string, void *ckt)
|
||||||
INPparseNode *p;
|
INPparseNode *p;
|
||||||
|
|
||||||
/* Make sure the case is ok. */
|
/* Make sure the case is ok. */
|
||||||
(void) strcpy(buf, string);
|
(void) strncpy(buf, string, 127);
|
||||||
|
buf[127] = 0;
|
||||||
strtolower(buf);
|
strtolower(buf);
|
||||||
|
|
||||||
p = TMALLOC(INPparseNode, 1);
|
p = TMALLOC(INPparseNode, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue