]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: make strtok() use more robust
authorKarel Zak <kzak@redhat.com>
Thu, 23 May 2019 12:18:29 +0000 (14:18 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 May 2019 12:18:29 +0000 (14:18 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.c

index f96e5bdf7e52a1c2c26a086d87adb415f91f3ac0..f0b9b7137b5e8b0996a7b2d18136c5bba7875c62 100644 (file)
@@ -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');
 }