Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# First get the TBF header from the correct binary in the TAB
tbfh = TBFHeader(binary)
if tbfh.is_valid():
# Check that total size actually matches the binary that we got.
if tbfh.get_app_size() < len(binary):
# It's fine if the binary is smaller, but the binary cannot be
# longer than the amount of reserved space (`total_size` in the
# TBF header) for the app.
raise TockLoaderException('Invalid TAB, the app binary is longer than its defined total_size')
tbfs.append((tbfh, binary[tbfh.get_size_before_app():]))
else:
raise TockLoaderException('Invalid TBF found in app in TAB')
return TabApp(tbfs)
tbf_filename = '{}.tbf'.format(tbf_name)
binary_tarinfo = self.tab.getmember(tbf_filename)
binary = self.tab.extractfile(binary_tarinfo).read()
# First get the TBF header from the correct binary in the TAB
tbfh = TBFHeader(binary)
if tbfh.is_valid():
# Check that total size actually matches the binary that we got.
if tbfh.get_app_size() < len(binary):
# It's fine if the binary is smaller, but the binary cannot be
# longer than the amount of reserved space (`total_size` in the
# TBF header) for the app.
raise TockLoaderException('Invalid TAB, the app binary is longer than its defined total_size')
return TabApp([(tbfh, binary[tbfh.get_size_before_app():])])
else:
raise TockLoaderException('Invalid TBF found in app in TAB')