@@ -164,8 +164,27 @@ static int vpc_check_signature(const void *buf)
static int vpc_probe(BlockDriverState *bs, const uint8_t *buf, int buf_size,
const char *filename)
{
- if (buf_size >= 8 && vpc_check_signature(buf))
- return 100;
+ char sig[8];
+
+ if (buf_size < 8) {
+ return 0;
+ }
+
+ if (vpc_check_signature(buf)) {
+ return 100;
+ }
+
+ /*
+ * Don't give up just yet, since the spec say that only dynamic
+ * images have a header (which in fact is a copy of the footer).
+ * Check the signature in the footer as well in order to handle
+ * fixed size images.
+ */
+ buf_size = bdrv_pread(bs, bdrv_getlength(bs) - HEADER_SIZE, sig, 8);
+ if (buf_size >= 8 && vpc_check_signature(sig)) {
+ return 100;
+ }
+
return 0;
}