diff options
author | Sami Kerola | 2013-01-19 01:09:02 +0100 |
---|---|---|
committer | Karel Zak | 2013-01-25 10:09:36 +0100 |
commit | ae6288da84ff6e6c70d4a9719b8935995022f65e (patch) | |
tree | 9d53b388430b7f697abaa03bcb70675b58ee7ad6 /sys-utils/dmesg.c | |
parent | tests: add dmesg(1) check (diff) | |
download | kernel-qcow2-util-linux-ae6288da84ff6e6c70d4a9719b8935995022f65e.tar.gz kernel-qcow2-util-linux-ae6288da84ff6e6c70d4a9719b8935995022f65e.tar.xz kernel-qcow2-util-linux-ae6288da84ff6e6c70d4a9719b8935995022f65e.zip |
dmesg: add boundary check to facility & level array usage
The dmesg should not crash while --decode'ing message facilities and
levels to readable string even if the values are out of bounds.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r-- | sys-utils/dmesg.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index f95db408d..ddab9b4ac 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -803,7 +803,9 @@ static void print_record(struct dmesg_control *ctl, /* * facility : priority : */ - if (ctl->decode && rec->level >= 0 && rec->facility >= 0) + if (ctl->decode && + -1 < rec->level && rec->level < (int) ARRAY_SIZE(level_names) && + -1 < rec->facility && rec->facility < (int) ARRAY_SIZE(facility_names)) printf("%-6s:%-6s: ", facility_names[rec->facility].name, level_names[rec->level].name); |