diff options
author | 2024-02-01 09:20:42 +0100 | |
---|---|---|
committer | 2024-02-01 09:20:42 +0100 | |
commit | 13b0eecccaeae428c5fcd58b9c7edf9854e154a3 (patch) | |
tree | 2d1c2d1e2d1a7696530a7d139716dbd5a37f3bb7 | |
parent | libq/contents: fix invalid access problem pointed out by valgrind (diff) | |
download | portage-utils-13b0eecccaeae428c5fcd58b9c7edf9854e154a3.tar.gz portage-utils-13b0eecccaeae428c5fcd58b9c7edf9854e154a3.tar.bz2 portage-utils-13b0eecccaeae428c5fcd58b9c7edf9854e154a3.zip |
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 <grobian@gentoo.org>
-rw-r--r-- | libq/tree.c | 6 |
1 files changed, 6 insertions, 0 deletions
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 { |