Skip to content

Commit 09473d4

Browse files
Merge pull request #9677 from vrothberg/fix-9672
podman load: fix error handling
2 parents 66ac942 + 930bec4 commit 09473d4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libpod/runtime_img.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
316316
} {
317317
src, err := referenceFn()
318318
if err == nil && src != nil {
319-
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
319+
newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer)
320+
if err == nil {
320321
return getImageNames(newImages), nil
321322
}
322323
saveErr = err

test/system/120-load.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ verify_iid_and_name() {
2626
is "$new_img_name" "$1" "Name & tag of restored image"
2727
}
2828

29+
@test "podman load invalid file" {
30+
# Regression test for #9672 to make sure invalid input yields errors.
31+
invalid=$PODMAN_TMPDIR/invalid
32+
echo "I am an invalid file and should cause a podman-load error" > $invalid
33+
run_podman 125 load -i $invalid
34+
}
35+
2936
@test "podman save to pipe and load" {
3037
# Generate a random name and tag (must be lower-case)
3138
local random_name=x0$(random_string 12 | tr A-Z a-z)

0 commit comments

Comments
 (0)