From: Thorsten Kukuk Date: Fri, 24 Jan 2025 16:06:48 +0000 (+0100) Subject: lslogins: don't ignore stat error X-Git-Tag: v2.42-start~70^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcf6d9a4ffb72f5e6a39b9f090350ce196e81440;p=thirdparty%2Futil-linux.git lslogins: don't ignore stat error Signed-off-by: Thorsten Kukuk --- diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index ebfdf6a79..a7152737a 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -498,10 +498,14 @@ static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **record /* optimize allocation according to file size, the realloc() below is * just fallback only */ - if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) { - imax = st.st_size / sizeof(struct utmpx); - ary = xreallocarray(NULL, imax, sizeof(struct utmpx)); - } + if (stat(path, &st) == 0) { + if ((size_t) st.st_size >= sizeof(struct utmpx)) { + imax = st.st_size / sizeof(struct utmpx); + ary = xreallocarray(NULL, imax, sizeof(struct utmpx)); + } else + return -ENODATA; + } else + return -errno; for (i = 0; ; i++) { struct utmpx *u;