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:
parent
a1790d265d
commit
fd7b0b4e54
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue