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

fix(ubi): add exception handler for SeekError #852

Merged
merged 2 commits into from
Jun 6, 2024
Merged

Conversation

mucoze
Copy link
Contributor

@mucoze mucoze commented May 15, 2024

This check is needed to exit the loop when the end of the file is reached.

@mucoze mucoze requested a review from qkaiser May 15, 2024 09:30
@qkaiser
Copy link
Contributor

qkaiser commented May 15, 2024

My understanding is that if a SeekError is raised, then the guessed PEB size is wrong or the UBI image is truncated. If the guessed PEB size is wrong, we should raise an InvalidInputFormat rather than silently returning a wrong offset.

What did you observe ? Was it a truncated image or the PEB is wrong ?

@mucoze
Copy link
Contributor Author

mucoze commented May 15, 2024

PEB size is correct.
I don't think the UBI images are truncated, given that they are valid samples and can also be properly extracted by ubireader_extract_images manually.

I'm observing SeekError on 3 different samples.

@qkaiser qkaiser self-assigned this Jun 5, 2024
@qkaiser qkaiser force-pushed the fix-ubi-seek-error branch 2 times, most recently from 54d5641 to ec69171 Compare June 5, 2024 11:52
@e3krisztian
Copy link
Contributor

I think the changes are fine, and could be merged.

I somewhat miss some means of test, that shows that it is working as intended.

Another potential problem I was thinking on is, when the _walk_ubi exits early due to the change resulting in a too small to be useful ubifs chunk. I think it is not a big issue, as it would fail at extraction time.

Would a minimal size check in _walk_ubi/calculate_chunk be valid and useful here?

@qkaiser
Copy link
Contributor

qkaiser commented Jun 6, 2024

@e3krisztian integration tests files demonstrating the behavior have been added by @mucoze

Would a minimal size check in _walk_ubi/calculate_chunk be valid and useful here?

Minimal size checks are usually arbitrary and not super useful IMO. As you said, failing case is not a big issue as it would fail at extraction time.

Mücahid KIR and others added 2 commits June 6, 2024 16:58
Truncated UBI images can lead to SeekError being raised. We now handle
that situation gracefully.
… reads.

Corrupt samples require the '-w' option so that we can actually extract
content.
@qkaiser qkaiser assigned mucoze and unassigned qkaiser Jun 6, 2024
@qkaiser qkaiser merged commit fde468c into main Jun 6, 2024
14 checks passed
@qkaiser qkaiser deleted the fix-ubi-seek-error branch June 6, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants