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: Handle error during decompression #1665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

friedrich-melchert
Copy link

During the decompression and therefore installation of the directory artifact the return value is not checked.

If the decompression fails (e.g. due to size constraints) the artifact install process continues in the same way it would for an successful decompression. This can leave the system in a corrupted state with a partially installed update.

This change fixes the issue by explicitly checking the return value of the decompression process and returning an error code in case of a failure.

Changelog: None
Ticket: None

During the decompression and therefore installation of the directory artifact the return value is not checked.

If the decompression fails (e.g. due to size constraints) the artifact install process continues in the same way it would for an successful decompression. This can leave the system in a corrupted state with a partially installed update. 

This change fixes the issue by explicitly checking the return value of the decompression process and returning an error code in case of a failure.

Changelog: None
Ticket: None

Signed-off-by: Friedrich Melchert <[email protected]>
@friedrich-melchert friedrich-melchert changed the title fix: Correclty handle error during decompression fix: Handle error during decompression Sep 13, 2024
@nickanderson nickanderson requested review from lluiscampos and a user September 13, 2024 13:42
@ghost ghost self-assigned this Sep 17, 2024
if ! tar -cf ${prev_files_tar} -C ${dest_dir} .

tar -cf ${prev_files_tar} -C ${dest_dir} .
createPrevSuccess=$?
Copy link

Choose a reason for hiding this comment

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

I think this won't work as intended because set -e is active. It will simply stop at the tar command once there is an error, because it's not part of a conditional, and won't continue to the next line.

I can't really see the problem with the previous code though, it looks correct to me. ret is being set, and is returned, as it should. The only thing missing is a more descriptive message. Are you saying this didn't work correctly for you?

Comment on lines 41 to +46
tar -xf ${update_files_tar} -C ${dest_dir}
extractSuccess=$?
if [ $extractSuccess -ne 0 ]
then
echo "Fatal error: something went wrong during artifact installation"
exit $extractSuccess
Copy link

Choose a reason for hiding this comment

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

Here too: This code will never be reached because of set -e.

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