]> 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)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 10 Oct 2023 19:00:48 +0000 (21:00 +0200)
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/path.c

index c878d2d9629be73dda55be8e145208bc0040494e..202f19ac4fc0d5a4e3d986100ec08db510eeba62 100644 (file)
@@ -1016,7 +1016,12 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
                goto out;
        }
 
-       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)