diff options
author | joerg <joerg@FreeBSD.org> | 1996-12-14 19:44:13 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-12-14 19:44:13 +0000 |
commit | 000a733206a490453542c9e437941673ec57912a (patch) | |
tree | 3f6b1c56b332fa464f32c498675cd4b15bef6ee2 | |
parent | 9395a75d3036be477ebade57b19f2db19bea8b82 (diff) | |
download | FreeBSD-src-000a733206a490453542c9e437941673ec57912a.zip FreeBSD-src-000a733206a490453542c9e437941673ec57912a.tar.gz |
Round #1 of cleaning up the config(8) mess. This is only the more
conservative part of the tidyup, like fixing potential buffer overflow
conditions. It is believed to be safe to go into 2.2.
Pointed out by: lozenko@cc.acnit.ac.ru (Evgeny A. Lozenko)
-rw-r--r-- | usr.sbin/config/config.y | 9 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 8 | ||||
-rw-r--r-- | usr.sbin/config/mkoptions.c | 12 |
3 files changed, 14 insertions, 15 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 7658111..91fbf24 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -358,28 +358,29 @@ device_name: = { char buf[80]; - (void) sprintf(buf, "%s%d", $1, $2); + (void) snprintf(buf, 80, "%s%d", $1, $2); $$ = ns(buf); free($1); } | Save_id NUMBER ID = { char buf[80]; - (void) sprintf(buf, "%s%d%s", $1, $2, $3); + (void) snprintf(buf, 80, "%s%d%s", $1, $2, $3); $$ = ns(buf); free($1); } | Save_id NUMBER ID NUMBER = { char buf[80]; - (void) sprintf(buf, "%s%d%s%d", $1, $2, $3, $4); + (void) snprintf(buf, 80, "%s%d%s%d", $1, $2, $3, $4); $$ = ns(buf); free($1); } | Save_id NUMBER ID NUMBER ID = { char buf[80]; - (void) sprintf(buf, "%s%d%s%d%s", $1, $2, $3, $4, $5); + (void) snprintf(buf, 80, "%s%d%s%d%s", + $1, $2, $3, $4, $5); $$ = ns(buf); free($1); } ; diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 7becfc8..513a503 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -256,12 +256,12 @@ read_files() struct device *save_dp; register struct opt *op; char *wd, *this, *needs, *special, *depends, *clean; - char fname[32]; + char fname[80]; int nreqs, first = 1, configdep, isdup, std, filetype, imp_rule, no_obj, before_depend; ftab = 0; - (void) strcpy(fname, "../../conf/files"); + (void) snprintf(fname, sizeof fname, "../../conf/files"); openit: fp = fopen(fname, "r"); if (fp == 0) { @@ -284,12 +284,12 @@ next: if (wd == (char *)EOF) { (void) fclose(fp); if (first == 1) { - (void) sprintf(fname, "files.%s", machinename); + (void) snprintf(fname, sizeof fname, "files.%s", machinename); first++; goto openit; } if (first == 2) { - (void) sprintf(fname, "files.%s", raise(ident)); + (void) snprintf(fname, sizeof fname, "files.%s", raise(ident)); first++; fp = fopen(fname, "r"); if (fp != 0) diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index f722d93..40fe87e 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -221,7 +221,7 @@ tooption(name) read_options() { FILE *fp; - char fname[32]; + char fname[80]; char *wd, *this, *val; struct opt_list *po; int first = 1; @@ -229,7 +229,7 @@ read_options() char *lower(); otab = 0; - (void) strcpy(fname, "../../conf/options"); + (void) snprintf(fname, sizeof fname, "../../conf/options"); openit: fp = fopen(fname, "r"); if (fp == 0) { @@ -244,12 +244,12 @@ next: if (wd == (char *)EOF) { (void) fclose(fp); if (first == 1) { - (void) sprintf(fname, "options.%s", machinename); + (void) snprintf(fname, sizeof fname, "options.%s", machinename); first++; goto openit; } if (first == 2) { - (void) sprintf(fname, "options.%s", raise(ident)); + (void) snprintf(fname, sizeof fname, "options.%s", raise(ident)); first++; fp = fopen(fname, "r"); if (fp != 0) @@ -274,9 +274,7 @@ next: return; if (val == 0) { char *s = ns(this); - (void) strcpy(genopt, "opt_"); - (void) strcat(genopt, lower(s)); - (void) strcat(genopt, ".h"); + (void) snprintf(genopt, sizeof genopt, "opt_%s.h", lower(s)); val = genopt; free(s); } |