summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMichal Mazurek <akfaew@cvs.openbsd.org>2016-09-12 14:33:13 +0000
committerMichal Mazurek <akfaew@cvs.openbsd.org>2016-09-12 14:33:13 +0000
commitc08e286fc4f5fa7cf9fcc1b7f52230ffa4f98eb9 (patch)
tree18d9875d94b6e4a1123c9ed762075667d7355ebd /usr.sbin
parente6b38d45e437a361b0db46c1392bacdf8f234dc7 (diff)
strlen + emalloc + snprintf = asprintf
ok deraadt@ tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/main.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 33d82e17a81..86fe1d6825d 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.50 2015/10/16 13:37:44 millert Exp $ */
+/* $OpenBSD: main.c,v 1.51 2016/09/12 14:33:12 akfaew Exp $ */
/* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */
/*
@@ -226,15 +226,13 @@ main(int argc, char *argv[])
last_component = strrchr(conffile, '/');
last_component = (last_component) ? last_component + 1 : conffile;
if (pflag) {
- int len = strlen(last_component) + 17;
- p = emalloc(len);
- (void)snprintf(p, len, "../compile/%s.PROF", last_component);
+ if (asprintf(&p, "../compile/%s.PROF", last_component) == -1)
+ err(1, NULL);
(void)addmkoption(intern("PROF"), "-pg");
(void)addoption(intern("GPROF"), NULL);
} else {
- int len = strlen(last_component) + 12;
- p = emalloc(len);
- (void)snprintf(p, len, "../compile/%s", last_component);
+ if (asprintf(&p, "../compile/%s", last_component) == -1)
+ err(1, NULL);
}
defbuilddir = (argc == 0) ? "." : p;