Skip to content

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 force-pushed the fix-ubi-seek-error branch from 1df65a9 to f6f8daa Compare June 5, 2024 10:11
@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
@qkaiser qkaiser force-pushed the fix-ubi-seek-error branch from ec69171 to 789dd3c Compare June 6, 2024 07:07
@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?

@e3krisztian e3krisztian self-requested a review June 6, 2024 08:51
@mucoze mucoze force-pushed the fix-ubi-seek-error branch from 789dd3c to de47659 Compare June 6, 2024 14:31
@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.
@mucoze mucoze force-pushed the fix-ubi-seek-error branch from de47659 to 9143144 Compare June 6, 2024 15:00
@qkaiser qkaiser assigned mucoze and unassigned qkaiser Jun 6, 2024
@qkaiser qkaiser merged commit fde468c into main Jun 6, 2024
@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.

5 participants