]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: don't ignore stat error
authorThorsten Kukuk <kukuk@suse.com>
Fri, 24 Jan 2025 16:06:48 +0000 (17:06 +0100)
committerThorsten Kukuk <kukuk@suse.com>
Mon, 27 Jan 2025 13:34:27 +0000 (14:34 +0100)
Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
login-utils/lslogins.c

index ebfdf6a79d6d606f27d8aa0ee2a8c9ef8ccce6ee..a7152737a4c3735313d3fe6add6496f4cfd103a7 100644 (file)
@@ -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;