Whamcloud - gitweb
e2p: fix segfault in e2p_os2string
authorAdam Buchbinder <abuchbinder@google.com>
Sat, 22 Jul 2017 21:52:24 +0000 (17:52 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 22 Jul 2017 21:52:30 +0000 (17:52 -0400)
Passing in a negative integer would lead to a segfault, and
a crafted filesystem image could trigger that.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/e2p/ostype.c

index 7f08844..c5fd8ab 100644 (file)
@@ -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)";