]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
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 7f088446baf7d329abc5a0b8f0733893d176599b..c5fd8ab3e7f1edd0dc2b499240def9525dd9b3dc 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)";