diff options
-rw-r--r-- | usr.bin/getconf/getconf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index 8bfeb93..14345c6 100644 --- a/usr.bin/getconf/getconf.c +++ b/usr.bin/getconf/getconf.c @@ -148,9 +148,14 @@ do_confstr(const char *name, int key) if (len == 0) { printf("undefined\n"); } else { - buf = alloca(len); - confstr(key, buf, len); - printf("%s\n", buf); + buf = malloc(len); + if (buf != NULL) { + confstr(key, buf, len); + printf("%s\n", buf); + free(buf); + } + else + err(EX_OSERR, "malloc: confstr"); } } |