|
|
cd9c77 |
From 199c328686aac174b0535619e5cea8450016e827 Mon Sep 17 00:00:00 2001
|
|
|
cd9c77 |
From: Karel Zak <kzak@redhat.com>
|
|
|
cd9c77 |
Date: Thu, 21 Oct 2021 18:47:40 +0200
|
|
|
cd9c77 |
Subject: logger: fix --size use for stdin
|
|
|
cd9c77 |
MIME-Version: 1.0
|
|
|
cd9c77 |
Content-Type: text/plain; charset=UTF-8
|
|
|
cd9c77 |
Content-Transfer-Encoding: 8bit
|
|
|
cd9c77 |
|
|
|
cd9c77 |
The stdin version counts log header into the message size, but
|
|
|
cd9c77 |
for example when it reads message from argv[] it counts only message
|
|
|
cd9c77 |
itself.
|
|
|
cd9c77 |
|
|
|
cd9c77 |
$ logger --stderr --size 3 "abcd"
|
|
|
cd9c77 |
<13>Oct 21 18:48:29 kzak: abc
|
|
|
cd9c77 |
|
|
|
cd9c77 |
$ echo "abcd" | logger --stderr --size 3
|
|
|
cd9c77 |
logger: cannot allocate 18446744073709551597 bytes: Cannot allocate memory
|
|
|
cd9c77 |
|
|
|
cd9c77 |
Upstream: http://github.com/util-linux/util-linux/commit/58e4ee082bca100034791a4a74481f263bb30a25
|
|
|
cd9c77 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2033622
|
|
|
cd9c77 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
cd9c77 |
---
|
|
|
cd9c77 |
misc-utils/logger.c | 9 +++------
|
|
|
cd9c77 |
1 file changed, 3 insertions(+), 6 deletions(-)
|
|
|
cd9c77 |
|
|
|
cd9c77 |
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
|
|
|
cd9c77 |
index 5b122de79..43284caeb 100644
|
|
|
cd9c77 |
--- a/misc-utils/logger.c
|
|
|
cd9c77 |
+++ b/misc-utils/logger.c
|
|
|
cd9c77 |
@@ -976,8 +976,7 @@ static void logger_stdin(struct logger_ctl *ctl)
|
|
|
cd9c77 |
int has_header = 1;
|
|
|
cd9c77 |
int default_priority = ctl->pri;
|
|
|
cd9c77 |
int last_pri = default_priority;
|
|
|
cd9c77 |
- size_t max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr);
|
|
|
cd9c77 |
- char *const buf = xmalloc(max_usrmsg_size + 2 + 2);
|
|
|
cd9c77 |
+ char *buf = xmalloc(ctl->max_message_size + 2 + 2);
|
|
|
cd9c77 |
int pri;
|
|
|
cd9c77 |
int c;
|
|
|
cd9c77 |
size_t i;
|
|
|
cd9c77 |
@@ -1004,16 +1003,14 @@ static void logger_stdin(struct logger_ctl *ctl)
|
|
|
cd9c77 |
ctl->pri = default_priority;
|
|
|
cd9c77 |
|
|
|
cd9c77 |
if (ctl->pri != last_pri) {
|
|
|
cd9c77 |
- has_header = 0;
|
|
|
cd9c77 |
- max_usrmsg_size =
|
|
|
cd9c77 |
- ctl->max_message_size - strlen(ctl->hdr);
|
|
|
cd9c77 |
+ generate_syslog_header(ctl);
|
|
|
cd9c77 |
last_pri = ctl->pri;
|
|
|
cd9c77 |
}
|
|
|
cd9c77 |
if (c != EOF && c != '\n')
|
|
|
cd9c77 |
c = getchar();
|
|
|
cd9c77 |
}
|
|
|
cd9c77 |
|
|
|
cd9c77 |
- while (c != EOF && c != '\n' && i < max_usrmsg_size) {
|
|
|
cd9c77 |
+ while (c != EOF && c != '\n' && i < ctl->max_message_size) {
|
|
|
cd9c77 |
buf[i++] = c;
|
|
|
cd9c77 |
c = getchar();
|
|
|
cd9c77 |
}
|
|
|
cd9c77 |
--
|
|
|
cd9c77 |
2.34.1
|
|
|
cd9c77 |
|