Skip to content

Conversation

@scriptkitz
Copy link

LEB1/LEB2 contains multiple MasterNodes. The one with the largest cmt_no needs to be scanned, as that is the currently activated one.

@qkaiser qkaiser self-requested a review August 25, 2025 09:17
@qkaiser qkaiser linked an issue Aug 25, 2025 that may be closed by this pull request
@qkaiser
Copy link
Contributor

qkaiser commented Aug 25, 2025

Related to #46

Copy link
Contributor

@qkaiser qkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Some further improvements can be made. See my comments.

Comment on lines -170 to +172
os.utime(path, (inode['ino'].atime_sec, inode['ino'].mtime_sec), follow_symlinks = False)
follow_symlinks = False
if os.name == 'nt': follow_symlinks = True
os.utime(path, (inode['ino'].atime_sec, inode['ino'].mtime_sec), follow_symlinks=follow_symlinks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to be unrelated. Please put it in a dedicated commit with a description explaining why you need to follow symlinks on Windows.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, On Windows, this parameter to False will error with Python 3.12, while True will not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Please put that in a dedicated commit.

Comment on lines +81 to +82
if crc != mst_chdr.crc:
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would log that the CRC32 does not match:

if crc != mst_chdr.crc:
    log(self, 'Master node CRC check failed: expected 0x%x got 0x%x' % (crc, mst_chdr.crc))

I'd continue working even in the presence of corrupt master node, this way the tool still extracts something. It may not be the most recent, but at least one that is not corrupt.

if crc != mst_chdr.crc:
    log(self, 'Master node CRC check failed: expected 0x%x got 0x%x' % (crc, mst_chdr.crc))
    mst_offset += mst_chdr.len
    continue

What do you think ?

Copy link
Author

@scriptkitz scriptkitz Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, masternodes are recorded in sequence. If a CRC failure occurs, there should be no normal ones afterwards. However, you can try continuing the scan. I'm not quite sure if the old data has been completely cleared.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objective is to be fault-tolerant since ubireader is used by unblob on a variety of weird firmware and image dumps.

@qkaiser
Copy link
Contributor

qkaiser commented Aug 26, 2025

@scriptkitz do you have some samples you could share ? Ideally a sample that extracts different content between the current main branch and yours. This way we can use it to catch future regressions.

@scriptkitz
Copy link
Author

@scriptkitz do you have some samples you could share ? Ideally a sample that extracts different content between the current main branch and yours. This way we can use it to catch future regressions.

USRDATA.zip
Here is a UBI file obtained from the device through fastboot fetch, and this file shows the above problem.

@qkaiser qkaiser self-assigned this Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Master node selection seems broken

2 participants