Skip to content

Commit

Permalink
Fix npe in exec resize when exec errored
Browse files Browse the repository at this point in the history
In cases where an exec start failed the exec process will be nil even
though the channel to signal that the exec started was closed.

Ideally ExecConfig would get a nice refactor to handle this case better
(ie. it's not started so don't close that channel).
This is a minimal fix to prevent NPE. Luckilly this would only get
called by a client and only the http request goroutine gets the panic
(http lib recovers the panic).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed May 28, 2023
1 parent 8f7bbc3 commit 487ea81
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions daemon/resize.go
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"strconv"
"time"

"github.com/docker/docker/errdefs"
)

// ContainerResize changes the size of the TTY of the process running
Expand Down Expand Up @@ -48,6 +50,10 @@ func (daemon *Daemon) ContainerExecResize(name string, height, width int) error

select {
case <-ec.Started:
// An error may have occurred, so ec.Process may be nil.
if ec.Process == nil {
return errdefs.InvalidParameter(errors.New("exec process is not started"))
}
return ec.Process.Resize(context.Background(), uint32(width), uint32(height))
case <-timeout.C:
return errors.New("timeout waiting for exec session ready")
Expand Down

0 comments on commit 487ea81

Please sign in to comment.