summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-03-10 05:26:56 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-03-10 05:26:56 +0000
commit5fbd62348c80dc3eb5063f996f85e93703996e4f (patch)
tree168334d941bbc985bd984872b2be54c2f5ab0916
parent7a46becad1021b8f571a84bdebc2b9acb9339e13 (diff)
Don't dereference NULL pointer if file is truncated.
Sync with cap_mkdb(1). ok otto and millert
-rw-r--r--lib/libc/gen/getcap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 65d0696ca1d..c3cd3bcd238 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getcap.c,v 1.23 2005/08/08 08:05:34 espie Exp $ */
+/* $OpenBSD: getcap.c,v 1.24 2006/03/10 05:26:55 ray Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -747,8 +747,13 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (-1);
}
+ /* Move on to next file. */
(void)fclose(pfp);
pfp = NULL;
+ ++dbp;
+ /* NUL terminate nbuf. */
+ *np = '\0';
+ break;
} else
/* XXX - assumes newline */
line[len - 1] = '\0';