From 44137c3b2607ab21178860c595689353efb54340 Mon Sep 17 00:00:00 2001 From: Adam Buchbinder Date: Sat, 22 Jul 2017 17:52:24 -0400 Subject: [PATCH] e2p: fix segfault in e2p_os2string Passing in a negative integer would lead to a segfault, and a crafted filesystem image could trigger that. Signed-off-by: Adam Buchbinder Signed-off-by: Theodore Ts'o --- lib/e2p/ostype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/e2p/ostype.c b/lib/e2p/ostype.c index 7f08844..c5fd8ab 100644 --- a/lib/e2p/ostype.c +++ b/lib/e2p/ostype.c @@ -30,7 +30,7 @@ char *e2p_os2string(int os_type) const char *os; char *ret; - if (os_type <= EXT2_OS_LITES) + if (os_type >= 0 && os_type <= EXT2_OS_LITES) os = os_tab[os_type]; else os = "(unknown os)"; -- 1.8.3.1