summaryrefslogtreecommitdiff
path: root/usr.bin/cap_mkdb
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/cap_mkdb')
-rw-r--r--usr.bin/cap_mkdb/getinfo.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/cap_mkdb/getinfo.c b/usr.bin/cap_mkdb/getinfo.c
index 160b806eb67..059c92f94b4 100644
--- a/usr.bin/cap_mkdb/getinfo.c
+++ b/usr.bin/cap_mkdb/getinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getinfo.c,v 1.8 2006/02/20 09:23:26 jmc Exp $ */
+/* $OpenBSD: getinfo.c,v 1.9 2006/03/10 05:20:35 ray Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -30,7 +30,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: getinfo.c,v 1.8 2006/02/20 09:23:26 jmc Exp $";
+static char rcsid[] = "$OpenBSD: getinfo.c,v 1.9 2006/03/10 05:20:35 ray Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -535,11 +535,12 @@ igetnext(char **bp, char **db_array)
for(;;) {
line = fgetln(pfp, &len);
if (line == NULL && pfp) {
- (void)fclose(pfp);
if (ferror(pfp)) {
(void)igetclose();
return (-1);
} else {
+ (void)fclose(pfp);
+ pfp = NULL;
if (*++dbp == NULL) {
(void)igetclose();
return (0);
@@ -551,7 +552,7 @@ igetnext(char **bp, char **db_array)
continue;
}
} else
- line[len - 1] = '\0';
+ line[len - 1] = '\0';/* XXX - assumes newline */
if (len == 1) {
slash = 0;
continue;
@@ -589,12 +590,19 @@ igetnext(char **bp, char **db_array)
} else { /* name field extends beyond the line */
line = fgetln(pfp, &len);
if (line == NULL && pfp) {
- (void)fclose(pfp);
if (ferror(pfp)) {
(void)igetclose();
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';
}
}