import binascii
from mic.utils.errors import MountError
-_GPT_HEADER_FORMAT = "<8s4sIIIQQQQ16sQIII420x"
+_GPT_HEADER_FORMAT = "<8s4sIIIQQQQ16sQIII"
_GPT_ENTRY_FORMAT = "<16s16sQQQ72s"
_SUPPORTED_GPT_REVISION = '\x00\x00\x01\x00'
(binascii.hexlify(header[1]),
binascii.hexlify(_SUPPORTED_GPT_REVISION)))
+ # Validate header size
+ if header[2] != struct.calcsize(_GPT_HEADER_FORMAT):
+ raise MountError("Bad GPT header size: %d bytes, expected %d" % \
+ (header[2], struct.calcsize(_GPT_HEADER_FORMAT)))
+
return (header[0], # 0. Signature
header[1], # 1. Revision
header[2], # 2. Header size in bytes