]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: Set errno in case of fgets failure
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 10 Oct 2023 19:00:48 +0000 (21:00 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Nov 2023 10:08:46 +0000 (11:08 +0100)
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/path.c

index 9a2d2bfb1965c7bb68764c33e8cf46a6bcd017dd..4aceda1a9511b738cffba73f8d4a5d8df764fdff 100644 (file)
@@ -1029,7 +1029,12 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
        if (!f)
                return -errno;
 
-       rc = fgets(buf, len, f) == NULL ? -EIO : 0;
+       if (fgets(buf, len, f) == NULL) {
+               errno = EIO;
+               rc = -errno;
+       } else
+               rc = 0;
+
        fclose(f);
 
        if (rc)