Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserved values res0/res1 error #1016

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion androguard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The current version of Androguard
# Please use only this variable in any scripts,
# to keep the version number the same everywhere.
__version__ = "4.1.0"
__version__ = "4.1.1"
15 changes: 8 additions & 7 deletions androguard/core/axml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2337,18 +2337,19 @@ def __init__(self, buff, parent=None):
self.id = unpack('<B', buff.read(1))[0]
self.res0 = unpack('<B', buff.read(1))[0]
self.res1 = unpack('<H', buff.read(2))[0]
# TODO: https://github.com/androguard/androguard/issues/1014 | Properly account for the cases where res0/1 are not zero
try:
if self.res0 != 0:
raise ResParserError("res0 must be zero!")
logger.warning("res0 must be zero!")
if self.res1 != 0:
raise ResParserError("res1 must be zero!")
logger.warning("res1 must be zero!")
self.entryCount = unpack('<I', buff.read(4))[0]

self.typespec_entries = []
for i in range(0, self.entryCount):
self.typespec_entries.append(unpack('<I', buff.read(4))[0])
except ResParserError as e:
logger.warning(e)
except Exception as e:
logger.error(e)

class ARSCResType:
"""
Expand Down Expand Up @@ -2943,12 +2944,12 @@ def __init__(self, buff, parent=None):
self.res0, = unpack("<B", buff.read(1))
try:
if self.res0 != 0:
raise ResParserError("res0 must be always zero!")
logger.warning("res0 must be always zero!")
self.data_type = unpack('<B', buff.read(1))[0]
# data is interpreted according to data_type
self.data = unpack('<I', buff.read(4))[0]
except ResParserError as e:
logger.warning(e)
except Exception as e:
logger.error(e)

def get_data_value(self):
return self.parent.stringpool_main.getString(self.data)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "androguard"
description = "Androguard is a full python tool to play with Android files."
authors = ["desnos <desnos@t0t0.fr>"]
version = "4.1.0"
version = "4.1.1"
license = "Apache Licence, Version 2.0"
readme = "README.md"
homepage = "https://github.com/androguard/androguard"
Expand Down