summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/mkmakefile.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-11-21 19:58:55 +0000
committerimp <imp@FreeBSD.org>2000-11-21 19:58:55 +0000
commitae30fcfec826cbc1aef366e520ae248267e5ac2e (patch)
treeaf280d537eb05b68e0199c48ee9a14999b89beb8 /usr.sbin/config/mkmakefile.c
parent92be31d0b583b42dee21f006ea62f231ad132326 (diff)
downloadFreeBSD-src-ae30fcfec826cbc1aef366e520ae248267e5ac2e.zip
FreeBSD-src-ae30fcfec826cbc1aef366e520ae248267e5ac2e.tar.gz
Fix buffer overflows in filenames. If you had a path > 80 characters
for your /usr/obj/path/to/my/files path to the kernel, then weird things happened. make buildkernel would fail because config was dumping core or generating bad file names (depending on the lenght of the path). While I was here, also use strlcpy, strlcat and snprintf (or asprintf) as necessary. Minor format policing for the snprintf calls as well.
Diffstat (limited to 'usr.sbin/config/mkmakefile.c')
-rw-r--r--usr.sbin/config/mkmakefile.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index bd110ec..e52c78a 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -49,6 +49,7 @@ static const char rcsid[] =
#include <err.h>
#include <stdio.h>
#include <string.h>
+#include <sys/param.h>
#include "y.tab.h"
#include "config.h"
#include "configvers.h"
@@ -286,7 +287,7 @@ read_files(void)
struct device *save_dp;
struct opt *op;
char *wd, *this, *needs, *special, *depends, *clean, *warn;
- char fname[80];
+ char fname[MAXPATHLEN];
int ddwarned = 0;
int nreqs, first = 1, configdep, isdup, std, filetype,
imp_rule, no_obj, needcount, before_depend, mandatory;
@@ -297,7 +298,7 @@ read_files(void)
printf("no ident line specified\n");
exit(1);
}
- (void) snprintf(fname, sizeof fname, "../../conf/files");
+ (void) snprintf(fname, sizeof(fname), "../../conf/files");
openit:
fp = fopen(fname, "r");
if (fp == 0)
@@ -316,16 +317,19 @@ next:
(void) fclose(fp);
if (first == 1) {
first++;
- (void) snprintf(fname, sizeof fname, "../../conf/files.%s", machinename);
+ (void) snprintf(fname, sizeof(fname),
+ "../../conf/files.%s", machinename);
fp = fopen(fname, "r");
if (fp != 0)
goto next;
- (void) snprintf(fname, sizeof fname, "files.%s", machinename);
+ (void) snprintf(fname, sizeof(fname),
+ "files.%s", machinename);
goto openit;
}
if (first == 2) {
first++;
- (void) snprintf(fname, sizeof fname, "files.%s", raisestr(ident));
+ (void) snprintf(fname, sizeof(fname),
+ "files.%s", raisestr(ident));
fp = fopen(fname, "r");
if (fp != 0)
goto next;
OpenPOWER on IntegriCloud