From 35f093ab7b01bcabbbef8b517945fa0f32950199 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 23 Jun 2023 12:09:07 +0200 Subject: key2root-rmkey, key2root-lskeys: check for NUL byte on truncated line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- key2root-rmkey.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'key2root-rmkey.c') 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); + } } -- cgit v1.2.3-70-g09d2