Skip to content

error when extracting a ubi file in blk.data_crc() function from ubireader #83

@arunmagesh

Description

@arunmagesh

There appears to be a bug in the ubireader which checks for crc information in the header and fails to catch if it doesn't recognise it properly.

To Reproduce
Steps to reproduce the behavior:

  1. Launch unblob with command unblob file.ubi
  2. See error

Detail
Error from unblob

code=0x1 pid=22412 severity=<Severity.WARNING: 'WARNING'> stderr=Traceback (most recent call last):
  File "/home/arunmag_001/.local/bin/ubireader_extract_images", line 143, in <module>
    ubi_obj = ubi(ufile_obj)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/__init__.py", line 146, in __init__
    super(ubi, self).__init__(ubi_file)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/__init__.py", line 46, in __init__
    self._blocks = extract_blocks(self)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/block/__init__.py", line 131, in extract_blocks
    blk.data_crc = (~crc32(buf[blk.ec_hdr.data_offset:blk.ec_hdr.data_offset+blk.vid_hdr.data_size]) & UBI_CRC32_INIT)
AttributeError: 'NoneType' object has no attribute 'data_size'

Same error from ubireader as well.

 ubireader_display_info 20000.ubi
Traceback (most recent call last):
  File "/home/arunmag_001/.local/bin/ubireader_display_info", line 132, in <module>
    ubi_obj = ubi(ufile_obj)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/__init__.py", line 146, in __init__
    super(ubi, self).__init__(ubi_file)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/__init__.py", line 46, in __init__
    self._blocks = extract_blocks(self)
  File "/home/arunmag_001/.local/lib/python3.10/site-packages/ubireader/ubi/block/__init__.py", line 131, in extract_blocks
    blk.data_crc = (~crc32(buf[blk.ec_hdr.data_offset:blk.ec_hdr.data_offset+blk.vid_hdr.data_size]) & UBI_CRC32_INIT)
AttributeError: 'NoneType' object has no attribute 'data_size'

Expected behavior
The script crash and fails to extract.

Environment information :
Linux arunmag 5.15.90.1-microsoft-standard-WSL2 onekey-sec/unblob#1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
"Ubuntu 22.04.1 LTS"
"unblob==23.4.17"

83886080-84803584.zip

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions