Whamcloud - gitweb
libext2fs: always refuse to open a file system with a zero s_desc_size
[tools/e2fsprogs.git] / lib / ext2fs / openfs.c
index fd56a9a..eb44d58 100644 (file)
@@ -330,13 +330,14 @@ retry:
        }
 
        /* Enforce the block group descriptor size */
-       if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
-           ext2fs_has_feature_64bit(fs->super)) {
+       if (ext2fs_has_feature_64bit(fs->super)) {
                unsigned desc_size = fs->super->s_desc_size;
 
-               if ((desc_size < EXT2_MIN_DESC_SIZE_64BIT) ||
-                   (desc_size > EXT2_MAX_DESC_SIZE) ||
-                   (desc_size & (desc_size - 1)) != 0) {
+               if (desc_size == 0 ||
+                   (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
+                    ((desc_size > EXT2_MAX_DESC_SIZE) ||
+                     (desc_size < EXT2_MIN_DESC_SIZE_64BIT) ||
+                     (desc_size & (desc_size - 1)) != 0))) {
                        retval = EXT2_ET_BAD_DESC_SIZE;
                        goto cleanup;
                }