]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: fix realloc() loop allocation size
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 22 Sep 2023 18:08:22 +0000 (20:08 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 22 Sep 2023 18:30:12 +0000 (20:30 +0200)
If stat() fails the realloc loop would always try to allocate zero
bytes.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
login-utils/lslogins.c

index ea5afb5ba6b1605fae15c51ddc510cbc8d9a0eed..c624302bd0d6c9cf54f2e801a693a1e82c8a17f1 100644 (file)
@@ -478,7 +478,7 @@ static struct utmpx *get_last_btmp(struct lslogins_control *ctl, const char *use
 
 static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **records)
 {
-       size_t i, imax = 0;
+       size_t i, imax = 1;
        struct utmpx *ary = NULL;
        struct stat st;