onekey-sec/unblob

Unhandled Exception during multi file calculation for multi-gzip handler

AndrewFasano opened this issue · 1 comments

An exception like this is raised for at least 371 ASUS firmware images. Tested on the head of main. (2e6a7ae)

Example firmware: https://dlcdnets.asus.com/pub/ASUS/wireless/RT-N66U_C1/FW_RT_N66U_C1_300438510000.zip

2024-02-14 21:33.04 [warning  ] Unhandled Exception during multi file calculation handler=multi-gzip path=host/FW_RT_N66U_C1_300438510000.zip_extract/Firmware_Release/RT-N66U_C1_3.0.0.4_385_10000-gd8ccd3c.trx_extract/part1_extract/0-40448000.squashfs_v4_l
e_extract/www/fb_data.tgz.gz.part.a pid=28 severity=<Severity.ERROR: 'ERROR'>
Traceback (most recent call last):
  File "/unblob/unblob/processing.py", line 377, in _calculate_multifile
    return dir_handler.calculate_multifile(path)
  File "/unblob/unblob/handlers/compression/gzip.py", line 177, in calculate_multifile
    if self.is_valid_gzip(file):
  File "/unblob/unblob/handlers/compression/gzip.py", line 159, in is_valid_gzip
    with File.from_path(path) as f:
  File "/unblob/unblob/file_utils.py", line 57, in from_path
    with path.open(mode) as base_file:
  File "/usr/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/host/FW_RT_N66U_C1_300438510000.zip_extract/Firmware_Release/RT-N66U_C1_3.0.0.4_385_10000-gd8ccd3c.trx_extract/part1_extract/0-40448000.squashfs_v4_le_extract/www/fb_data.tgz.gz.part.a'

It's triggered by the fact that those files are symlinks pointing to content that is not there (probably provisioned or moved during boot):

ls -l *gz* 
lrwxrwxrwx 1 quentin quentin 21 feb 15 11:27 fb_data.tgz.gz -> ../tmp/fb_data.tgz.gz
lrwxrwxrwx 1 quentin quentin 28 feb 15 11:27 fb_data.tgz.gz.part.a -> ../tmp/fb_data.tgz.gz.part.a
lrwxrwxrwx 1 quentin quentin 28 feb 15 11:27 fb_data.tgz.gz.part.b -> ../tmp/fb_data.tgz.gz.part.b
lrwxrwxrwx 1 quentin quentin 28 feb 15 11:27 fb_data.tgz.gz.part.c -> ../tmp/fb_data.tgz.gz.part.c
lrwxrwxrwx 1 quentin quentin 28 feb 15 11:27 fb_data.tgz.gz.part.d -> ../tmp/fb_data.tgz.gz.part.d