From 13b0eecccaeae428c5fcd58b9c7edf9854e154a3 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 1 Feb 2024 09:20:42 +0100 Subject: libq/tree: handle hypothetical fail in tree_pkg_meta_get_int When we cannot read all bytes from a file, return an empty string, not partial garbage. Signed-off-by: Fabian Groffen --- libq/tree.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libq/tree.c b/libq/tree.c index 15d8267..4678634 100644 --- a/libq/tree.c +++ b/libq/tree.c @@ -1233,6 +1233,12 @@ tree_pkg_meta_get_int(tree_pkg_ctx *pkg_ctx, size_t offset, const char *keyn) p[--s.st_size] = '\0'; m->storage->pos += s.st_size + 1; } + else + { + /* hmmm, couldn't read the whole file?!? */ + p[0] = '\0'; + m->storage->pos++; + } close(fd); } } else { -- cgit v1.2.3-65-gdbad