]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/env: avoid underflow of read_all_alloc() return value
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 22 Sep 2023 09:19:37 +0000 (11:19 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 22 Sep 2023 18:22:21 +0000 (20:22 +0200)
read_all_alloc() returns a negative error on failure.
When casting this to an unsigned type the failure check "< 1"
will not work.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
lib/env.c

index 2ccabff6fc2ae0e9aa25dc516578180299659b46..2b3395c53b86d1e8a36715756562502e7d28dda0 100644 (file)
--- a/lib/env.c
+++ b/lib/env.c
@@ -90,7 +90,7 @@ static struct ul_env_list *env_list_add(struct ul_env_list *ls0, const char *str
 struct ul_env_list *env_from_fd(int fd)
 {
        char *buf = NULL, *p;
-       size_t rc = 0;
+       ssize_t rc = 0;
        struct ul_env_list *ls = NULL;
 
        if ((rc = read_all_alloc(fd, &buf)) < 1)