pkg/bindings: fix infinite loop/memory leak in image pull
In the case of an Decoder error which is not EOF we loop forever, as the Decoder stores some errors each next Decode() call will keep returning the same error. Thus we loop forever until we run out of memory as each error was stored in pullErrors array as described in [1]. Note this does not actually fix whatever causes the underlying connection error in the issue, it just fixes the loop/memory leak. [1] https://github.com/containers/podman/issues/25974 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
b4954ac2e8
commit
6c0e581fa9
|
|
@ -74,9 +74,16 @@ LOOP:
|
|||
var report types.ImagePullReport
|
||||
if err := dec.Decode(&report); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// end of stream, exit loop
|
||||
break
|
||||
}
|
||||
report.Error = err.Error() + "\n"
|
||||
// Decoder error, it is unlikely that the next call would work again
|
||||
// so exit here as well, the Decoder can store the error and always
|
||||
// return the same one for all future calls which then causes a
|
||||
// infinity loop and memory leak in pullErrors.
|
||||
// https://github.com/containers/podman/issues/25974
|
||||
pullErrors = append(pullErrors, fmt.Errorf("failed to decode message from stream: %w", err))
|
||||
break
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
|||
Loading…
Reference in New Issue