aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--key2root-lskeys.c4
-rw-r--r--key2root-rmkey.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/key2root-lskeys.c b/key2root-lskeys.c
index 271b0a9..a25b32d 100644
--- a/key2root-lskeys.c
+++ b/key2root-lskeys.c
@@ -103,8 +103,10 @@ listkeys(int dir, const char *user)
}
if (rhead != whead) {
- fprintf(stderr, "%s: file truncated: %s/%s\n", argv0, KEYPATH, user);
failed = 1;
+ fprintf(stderr, "%s: file truncated: %s/%s\n", argv0, KEYPATH, user);
+ if (memchr(&data[rhead], '\0', whead - rhead))
+ fprintf(stderr, "%s: NUL byte found in %s/%s on line %zu\n", argv0, KEYPATH, user, lineno + 1);
}
close(fd);
diff --git a/key2root-rmkey.c b/key2root-rmkey.c
index c55468f..1165435 100644
--- a/key2root-rmkey.c
+++ b/key2root-rmkey.c
@@ -116,8 +116,11 @@ loadandremove(int fd, char **datap, size_t *lenp, size_t *sizep, const char **ke
removekeys(*datap, lenp, &rhead, &rhead2, &lineno, path, keys, nkeysp);
}
- if (rhead != *lenp)
+ if (rhead != *lenp) {
fprintf(stderr, "%s: file truncated: %s\n", argv0, path);
+ if (memchr(&(*datap)[rhead], '\0', *lenp - rhead))
+ fprintf(stderr, "%s: NUL byte found in %s on line %zu\n", argv0, path, lineno + 1);
+ }
}