summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2019-05-23 14:18:29 +0200
committerKarel Zak2019-05-23 14:18:29 +0200
commit2d278988442d3f4ac43cd0eb441fc92aa570dc05 (patch)
treea6598b277747370f3de8960ee15e3290b17c297a /sys-utils
parentblkzone: remove never read value (diff)
downloadkernel-qcow2-util-linux-2d278988442d3f4ac43cd0eb441fc92aa570dc05.tar.gz
kernel-qcow2-util-linux-2d278988442d3f4ac43cd0eb441fc92aa570dc05.tar.xz
kernel-qcow2-util-linux-2d278988442d3f4ac43cd0eb441fc92aa570dc05.zip
dmesg: make strtok() use more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/dmesg.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index f96e5bdf7..f0b9b7137 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');
}