Skip to content

Commit

Permalink
fix 1017 by checking the size for ARSCResTableConfig for anything abo…
Browse files Browse the repository at this point in the history
…ve the first 16 bytes
  • Loading branch information
erev0s committed Mar 23, 2024
1 parent f01be41 commit 7dee783
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions androguard/core/axml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2433,22 +2433,34 @@ def __init__(self, buff=None, **kwargs):
# uint16_t density
self.screenType = unpack('<I', buff.read(4))[0]

# struct of
# uint8_t keyboard
# uint8_t navigation
# uint8_t inputFlags
# uint8_t inputPad0
self.input = unpack('<I', buff.read(4))[0]

# struct of
# uint16_t screenWidth
# uint16_t screenHeight
self.screenSize = unpack('<I', buff.read(4))[0]

# struct of
# uint16_t sdkVersion
# uint16_t minorVersion which should be always 0, as the meaning is not defined
self.version = unpack('<I', buff.read(4))[0]
if self.size >= 20:
# struct of
# uint8_t keyboard
# uint8_t navigation
# uint8_t inputFlags
# uint8_t inputPad0
self.input = unpack('<I', buff.read(4))[0]
else:
logger.debug("This file does not have input flags! size={}".format(self.size))
self.input = 0

if self.size >= 24:
# struct of
# uint16_t screenWidth
# uint16_t screenHeight
self.screenSize = unpack('<I', buff.read(4))[0]
else:
logger.debug("This file does not have screenSize! size={}".format(self.size))
self.screenSize = 0

if self.size >= 28:
# struct of
# uint16_t sdkVersion
# uint16_t minorVersion which should be always 0, as the meaning is not defined
self.version = unpack('<I', buff.read(4))[0]
else:
logger.debug("This file does not have version! size={}".format(self.size))
self.version = 0

# The next three fields seems to be optional
if self.size >= 32:
Expand Down

0 comments on commit 7dee783

Please sign in to comment.