]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: more robust minix probing
authorKarel Zak <kzak@redhat.com>
Mon, 8 Mar 2010 12:05:09 +0000 (13:05 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 8 Mar 2010 12:05:09 +0000 (13:05 +0100)
Unfortunately, it's still possible to interpret some parts of ext3
filesystem as minix superblock ;-(

So, the most robust is to check for the extN magic string in minix
probing function.

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=570606
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/superblocks/minix.c

index 7b314abc9e548e7d55be05eed0f47775ca6991ae..3290c275565d1480b32263aab7758d370aea52c7 100644 (file)
@@ -9,6 +9,7 @@
  * GNU Lesser General Public License.
  */
 
+#include <string.h>
 #include "superblocks.h"
 
 struct minix_super_block {
@@ -45,6 +46,7 @@ struct minix3_super_block {
 
 static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag)
 {
+       unsigned char *ext;
        int version;
 
        /* for more details see magic strings below */
@@ -88,6 +90,14 @@ static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag)
 
        }
 
+       /* unfortunately, some parts of ext3 is sometimes possible to
+        * interpreted as minix superblock. So check for extN magic
+        * string. (For extN magic string and offsets see ext.c.)
+        */
+       ext = blkid_probe_get_buffer(pr, 0x400 + 0x38, 2);
+       if (ext && memcmp(ext, "\123\357", 2) == 0)
+               return -1;
+
        blkid_probe_sprintf_version(pr, "%d", version);
        return 0;
 }