Skip to content

ksud: don't panic on a broken zip in get_zip_uncompressed_size - #3591

Open
palazik wants to merge 1 commit into
tiann:mainfrom
palazik:fix/ksud-zip-size-error
Open

ksud: don't panic on a broken zip in get_zip_uncompressed_size#3591
palazik wants to merge 1 commit into
tiann:mainfrom
palazik:fix/ksud-zip-size-error

Conversation

@palazik

@palazik palazik commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

get_zip_uncompressed_size iterates the archive with by_index(i).unwrap(). If any entry can't be read the unwrap() panics and the whole ksud process dies.

This is reachable from module install: hand it a truncated or corrupted zip and instead of a clean "failed to read module" error you get a panic.

Since the function already returns Result<u64>, the simple fix is to propagate the error with ?:

let mut total: u64 = 0;
for i in 0..zip.len() {
    total += zip.by_index(i)?.size();
}
Ok(total)

No behavior change for valid archives.

by_index() was unwrapped, so a zip with an entry we can't read (e.g. a
truncated or otherwise broken archive handed to `module install`) takes
down the whole ksud process instead of surfacing an error.

The function already returns Result, so just use `?` and sum in a loop.
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.

1 participant