summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@intel.com>2013-04-09 17:48:25 +0300
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2013-04-19 16:23:19 +0300
commitcbf20bb9d118e377ff8ffc2fa6d06501a8b87794 (patch)
tree5b73c1930754bb42ad2a7b698c8b67d10ef38bcb
parent57b5f9d671b718e0b07a96903ed0f2ba71e45d33 (diff)
downloadmic-cbf20bb9d118e377ff8ffc2fa6d06501a8b87794.tar.gz
mic-cbf20bb9d118e377ff8ffc2fa6d06501a8b87794.tar.bz2
mic-cbf20bb9d118e377ff8ffc2fa6d06501a8b87794.zip
gpt_parser: validate header size
Change-Id: I7cb08dff3421f3390525c0fc4c5188d15ce90e53 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
-rw-r--r--mic/utils/gpt_parser.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mic/utils/gpt_parser.py b/mic/utils/gpt_parser.py
index 7cf61e5..f2abdb8 100644
--- a/mic/utils/gpt_parser.py
+++ b/mic/utils/gpt_parser.py
@@ -23,7 +23,7 @@ import uuid
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'
@@ -94,6 +94,11 @@ class GptParser:
(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