dmesg: do not stop on \0

... but I have doubts this change fixes the issue. It seems (on my
system) that \0 is already filtered out by kernel/syslog.

Addresses: https://github.com/karelzak/util-linux/issues/862
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-09-10 10:34:01 +02:00
parent a1790d265d
commit fd7b0b4e54
1 changed files with 6 additions and 1 deletions

View File

@ -623,6 +623,7 @@ static void safe_fwrite(struct dmesg_control *ctl, const char *buf, size_t size,
size_t i;
#ifdef HAVE_WIDECHAR
mbstate_t s;
wchar_t wc;
memset(&s, 0, sizeof (s));
#endif
for (i = 0; i < size; i++) {
@ -631,8 +632,11 @@ static void safe_fwrite(struct dmesg_control *ctl, const char *buf, size_t size,
size_t len = 1;
if (!ctl->noesc) {
if (*p == '\0') {
hex = 1;
goto doprint;
}
#ifdef HAVE_WIDECHAR
wchar_t wc;
len = mbrtowc(&wc, p, size - i, &s);
if (len == 0) /* L'\0' */
@ -656,6 +660,7 @@ static void safe_fwrite(struct dmesg_control *ctl, const char *buf, size_t size,
}
}
doprint:
if (hex)
rc = fwrite_hex(p, len, out);
else if (*p == '\n' && *(p + 1) && indent) {