From: Tobias Stoeckmann Date: Tue, 10 Oct 2023 19:00:48 +0000 (+0200) Subject: lib/path: Set errno in case of fgets failure X-Git-Tag: v2.39.3~32 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ca6f1712a5803e32e26e065e32e99837ba8b5d2;p=thirdparty%2Futil-linux.git lib/path: Set errno in case of fgets failure Signed-off-by: Tobias Stoeckmann --- diff --git a/lib/path.c b/lib/path.c index 9a2d2bfb19..4aceda1a95 100644 --- a/lib/path.c +++ b/lib/path.c @@ -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)