Skip to content

Commit 1e4287d

Browse files
Merge pull request #26010 from Luap99/bindings-pull
pkg/bindings: fix infinite loop/memory leak in image pull
2 parents b4954ac + 579b174 commit 1e4287d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/bindings/images/pull.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@ LOOP:
7474
var report types.ImagePullReport
7575
if err := dec.Decode(&report); err != nil {
7676
if errors.Is(err, io.EOF) {
77+
// end of stream, exit loop
7778
break
7879
}
79-
report.Error = err.Error() + "\n"
80+
// Decoder error, it is unlikely that the next call would work again
81+
// so exit here as well, the Decoder can store the error and always
82+
// return the same one for all future calls which then causes a
83+
// infinity loop and memory leak in pullErrors.
84+
// https://github.com/containers/podman/issues/25974
85+
pullErrors = append(pullErrors, fmt.Errorf("failed to decode message from stream: %w", err))
86+
break
8087
}
8188

8289
select {

pkg/bindings/images/push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ LOOP:
7474
if errors.Is(err, io.EOF) {
7575
break
7676
}
77-
return err
77+
return fmt.Errorf("failed to decode message from stream: %w", err)
7878
}
7979

8080
select {

0 commit comments

Comments
 (0)