From: Karel Zak Date: Thu, 23 May 2019 12:18:29 +0000 (+0200) Subject: dmesg: make strtok() use more robust X-Git-Tag: v2.34-rc2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d278988442d3f4ac43cd0eb441fc92aa570dc05;p=thirdparty%2Futil-linux.git dmesg: make strtok() use more robust Signed-off-by: Karel Zak --- diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index f96e5bdf7e..f0b9b7137b 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -1017,6 +1017,8 @@ full_output: if (!line) { mesg_copy = xstrdup(rec->mesg); line = strtok(mesg_copy, "\n"); + if (!line) + goto done; /* only when something is wrong */ mesg_size = strlen(line); } } else { @@ -1057,6 +1059,7 @@ full_output: free(mesg_copy); } +done: putchar('\n'); }