]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: avoid mess at the end of dmesg output
authorPetr Uzel <petr.uzel@suse.cz>
Wed, 10 Aug 2011 12:16:40 +0000 (14:16 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Aug 2011 12:28:21 +0000 (14:28 +0200)
Since util-linux commit a7ee94f2204011f26232ed3133514bf6e0d4a62c,
dmesg incorrectly calculates number of bytes that are remaining in the
buffer in get_next_record(). This could, under specific circumstances,
cause printing mess at the end of dmesg output:

> dmesg | tail
[ 1191.478725] Adding 285488k swap on /root/swapfile.  Priority:-2 extents:15 across:1186612k
[ 1205.588331] Adding 285488k swap on /root/swapfile.  Priority:-2 extents:15 across:1186612k
\xffffffba\xffffffba

Reported-by: Glenn Doig <doiggl@velocitynet.com.au>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=710417

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
sys-utils/dmesg.c

index 94f8c111d87ffc1c2314121194ed63f0d9605a2f..705269db0db7ed3bf32d2156620c66d775e5ff36 100644 (file)
@@ -494,6 +494,8 @@ static int get_next_record(struct dmesg_control *ctl, struct dmesg_record *rec)
 
                rec->next_size -= end - rec->next;
                rec->next = rec->next_size > 0 ? end + 1 : NULL;
+               if (rec->next_size > 0)
+                       rec->next_size--;
 
                return 0;
        }