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@xxxxxx> --- sys-utils/dmesg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index f95db40..ddab9b4 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); -- 1.8.1.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html