aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorWojciech A. Koszek <wkoszek@FreeBSD.org>2009-02-06 00:50:21 +0000
committerWojciech A. Koszek <wkoszek@FreeBSD.org>2009-02-06 00:50:21 +0000
commitd030e65009d56a9d3bbb72a543321538d2efa422 (patch)
treecd7cfe7c060965becc28970de0da2c18ceb5317a /usr.sbin
parent506c6a3a3d298d6153aaefeb03b36dc21894b6de (diff)
Notes
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/config/main.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 24b439606bd28..58d6f2a435a02 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -669,7 +669,7 @@ kernconfdump(const char *file)
struct stat st;
FILE *fp, *pp;
int error, len, osz, r;
- unsigned int off, size;
+ unsigned int i, off, size;
char *cmd, *o;
r = open(file, O_RDONLY);
@@ -707,7 +707,18 @@ kernconfdump(const char *file)
r = fseek(fp, off, SEEK_CUR);
if (r != 0)
errx(EXIT_FAILURE, "fseek() failed");
- while ((r = fgetc(fp)) != EOF && size-- > 0)
+ for (i = 0; i < size - 1; i++) {
+ r = fgetc(fp);
+ if (r == EOF)
+ break;
+ /*
+ * If '\0' is present in the middle of the configuration
+ * string, this means something very weird is happening.
+ * Make such case very visible.
+ */
+ assert(r != '\0' && ("Char present in the configuration "
+ "string mustn't be equal to 0"));
fputc(r, stdout);
+ }
fclose(fp);
}