mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
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)
This commit is contained in:
parent
472ba2f1ca
commit
f0b48d9876
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20457
3 changed files with 14 additions and 15 deletions
|
@ -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);
|
||||
}
|
||||
;
|
||||
|
|
|
@ -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 @@ read_files()
|
|||
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)
|
||||
|
|
|
@ -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 @@ read_options()
|
|||
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 @@ read_options()
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue