From 74b1659ddaac4aa409b56d1eaa07d87b5b11b98e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 8 Mar 2010 13:05:09 +0100 Subject: [PATCH] libblkid: more robust minix probing 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 --- shlibs/blkid/src/superblocks/minix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shlibs/blkid/src/superblocks/minix.c b/shlibs/blkid/src/superblocks/minix.c index 7b314abc..3290c275 100644 --- a/shlibs/blkid/src/superblocks/minix.c +++ b/shlibs/blkid/src/superblocks/minix.c @@ -9,6 +9,7 @@ * GNU Lesser General Public License. */ +#include #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; } -- 2.39.5