diff --git a/lib/appliance-kcmdline.c b/lib/appliance-kcmdline.c index 8b78655eb..092d37329 100644 --- a/lib/appliance-kcmdline.c +++ b/lib/appliance-kcmdline.c @@ -65,7 +65,7 @@ static char * get_root_uuid_with_file (guestfs_h *g, const char *appliance) { - unsigned char magic[2], uuid[16]; + unsigned char magic[4], uuid[16]; char *ret; int fd; @@ -74,6 +74,10 @@ get_root_uuid_with_file (guestfs_h *g, const char *appliance) perrorf (g, _("open: %s"), appliance); return NULL; } + if (read (fd, magic, 4) != 4 || !strncmp ((char *) magic, "QFI\xfb", 4)) { + /* No point looking for extfs signature in QCOW2 directly. */ + return NULL; + } if (lseek (fd, 0x438, SEEK_SET) != 0x438) { magic_error: error (g, _("%s: cannot read extfs magic in superblock"), appliance);