|
|
673c78 |
From c269e116ea4d9e96a5f5801aecf1f624199fa6ec Mon Sep 17 00:00:00 2001
|
|
|
673c78 |
From: Karel Zak <kzak@redhat.com>
|
|
|
673c78 |
Date: Tue, 7 Jun 2022 09:46:54 +0200
|
|
|
673c78 |
Subject: lslogins: fix free(): invalid pointer
|
|
|
673c78 |
|
|
|
673c78 |
Upstream: http://github.com/util-linux/util-linux/commit/890d4d3f236e2d28db35ea9bc9dc3e5e35db975c
|
|
|
673c78 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
|
|
|
673c78 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
673c78 |
---
|
|
|
673c78 |
login-utils/lslogins.c | 5 ++++-
|
|
|
673c78 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
673c78 |
|
|
|
673c78 |
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
|
|
|
673c78 |
index 1332a9925..ff4386d1b 100644
|
|
|
673c78 |
--- a/login-utils/lslogins.c
|
|
|
673c78 |
+++ b/login-utils/lslogins.c
|
|
|
673c78 |
@@ -488,7 +488,7 @@ static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **record
|
|
|
673c78 |
|
|
|
673c78 |
/* optimize allocation according to file size, the realloc() below is
|
|
|
673c78 |
* just fallback only */
|
|
|
673c78 |
- if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) {
|
|
|
673c78 |
+ if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) {
|
|
|
673c78 |
imax = st.st_size / sizeof(struct utmpx);
|
|
|
673c78 |
ary = xmalloc(imax * sizeof(struct utmpx));
|
|
|
673c78 |
}
|
|
|
673c78 |
@@ -1007,6 +1007,9 @@ static void free_ctl(struct lslogins_control *ctl)
|
|
|
673c78 |
{
|
|
|
673c78 |
size_t n = 0;
|
|
|
673c78 |
|
|
|
673c78 |
+ if (!ctl)
|
|
|
673c78 |
+ return;
|
|
|
673c78 |
+
|
|
|
673c78 |
free(ctl->wtmp);
|
|
|
673c78 |
free(ctl->btmp);
|
|
|
673c78 |
|
|
|
673c78 |
--
|
|
|
673c78 |
2.36.1
|
|
|
673c78 |
|