]> 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)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Nov 2023 09:47:47 +0000 (10:47 +0100)
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 76d28125c90a03d96a05659ec51f7080a6797bc3..effaba4b48baf0031488ef177640358e4ed2dcad 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;