summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Tolvanen2016-03-29 18:06:37 -0500
committerSami Tolvanen2016-03-29 18:06:37 -0500
commit294eb9dac3c06a37bc1c9547fa8a26bcf4cdc749 (patch)
tree6ad76631ad6e71f645349ba5fba9899a34f4e9f4 /mkbootimg
parentfbdbf100cb48f18d308c96f1959945cf7d1909ec (diff)
downloadplatform-system-core-294eb9dac3c06a37bc1c9547fa8a26bcf4cdc749.tar.gz
platform-system-core-294eb9dac3c06a37bc1c9547fa8a26bcf4cdc749.tar.xz
platform-system-core-294eb9dac3c06a37bc1c9547fa8a26bcf4cdc749.zip
mkbootimg: use int for os_version and os_patch_level
The parse_int function attempts to interpret the string to detect base, which leads to it assuming strings starting with 0 are base 8. This obviously fails for certain dates, so use int instead. Bug: 27498078 Bug: 22914603 Change-Id: I50b1fb3d7876f2ec17d00649cc9a2d23af2aec2b
Diffstat (limited to 'mkbootimg')
-rwxr-xr-xmkbootimg/mkbootimg10
1 files changed, 5 insertions, 5 deletions
diff --git a/mkbootimg/mkbootimg b/mkbootimg/mkbootimg
index 7b04bcc7b..5a13da26b 100755
--- a/mkbootimg/mkbootimg
+++ b/mkbootimg/mkbootimg
@@ -102,12 +102,12 @@ def parse_int(x):
102def parse_os_version(x): 102def parse_os_version(x):
103 match = re.search(r'^(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3}))?)?', x) 103 match = re.search(r'^(\d{1,3})(?:\.(\d{1,3})(?:\.(\d{1,3}))?)?', x)
104 if match: 104 if match:
105 a = parse_int(match.group(1)) 105 a = int(match.group(1))
106 b = c = 0 106 b = c = 0
107 if match.lastindex >= 2: 107 if match.lastindex >= 2:
108 b = parse_int(match.group(2)) 108 b = int(match.group(2))
109 if match.lastindex == 3: 109 if match.lastindex == 3:
110 c = parse_int(match.group(3)) 110 c = int(match.group(3))
111 # 7 bits allocated for each field 111 # 7 bits allocated for each field
112 assert a < 128 112 assert a < 128
113 assert b < 128 113 assert b < 128
@@ -118,8 +118,8 @@ def parse_os_version(x):
118def parse_os_patch_level(x): 118def parse_os_patch_level(x):
119 match = re.search(r'^(\d{4})-(\d{2})-(\d{2})', x) 119 match = re.search(r'^(\d{4})-(\d{2})-(\d{2})', x)
120 if match: 120 if match:
121 y = parse_int(match.group(1)) - 2000 121 y = int(match.group(1)) - 2000
122 m = parse_int(match.group(2)) 122 m = int(match.group(2))
123 # 7 bits allocated for the year, 4 bits for the month 123 # 7 bits allocated for the year, 4 bits for the month
124 assert y >= 0 and y < 128 124 assert y >= 0 and y < 128
125 assert m > 0 and m <= 12 125 assert m > 0 and m <= 12