summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-12-04 15:05:20 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-12-04 15:05:20 +0000
commitc726c7f2258cf05ee71bb1784d1b4d2a35193c4b (patch)
treee58a6ddbee00e7b443e198b8dee7343ab0d9ba85 /usr.bin
parentb5af6deedd783c955c9695acbeddeef0db01ddbe (diff)
check confstr() return value. Due to the braindead return value
specified by POSIX we have to clear errno before; also check for -1 to remain compatible. ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/getconf/getconf.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c
index 89925911875..f889545e2a0 100644
--- a/usr.bin/getconf/getconf.c
+++ b/usr.bin/getconf/getconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getconf.c,v 1.9 2003/07/10 00:06:51 david Exp $ */
+/* $OpenBSD: getconf.c,v 1.10 2006/12/04 15:05:19 otto Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: getconf.c,v 1.9 2003/07/10 00:06:51 david Exp $";
+static char rcsid[] = "$OpenBSD: getconf.c,v 1.10 2006/12/04 15:05:19 otto Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -188,8 +188,15 @@ main(int argc, char *argv[])
break;
case CONFSTR:
+ errno = 0;
slen = confstr (cp->value, (char *) 0, (size_t) 0);
-
+
+ if (slen == 0 || slen == (size_t)-1) {
+ if (errno)
+ err(1, "%s", cp->value);
+ else
+ errx(1, "%s", cp->value);
+ }
if ((sval = malloc(slen)) == NULL)
err(1, NULL);