Skip to content

Commit

Permalink
Fix a segfault in 'podman ps --sync'
Browse files Browse the repository at this point in the history
We weren't properly populating the container's OCI Runtime in
Batch(), causing segfaults on attempting to access it. Add a test
to make sure we actually catch cases like this in the future.

Fixes containers#3411

Signed-off-by: Matthew Heon <[email protected]>
  • Loading branch information
mheon committed Jun 24, 2019
1 parent b611ac1 commit de75b1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions libpod/container_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ func (c *Container) Batch(batchFunc func(*Container) error) error {
newCtr.config = c.config
newCtr.state = c.state
newCtr.runtime = c.runtime
newCtr.ociRuntime = c.ociRuntime
newCtr.lock = c.lock
newCtr.valid = true

Expand Down
12 changes: 12 additions & 0 deletions test/e2e/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,16 @@ var _ = Describe("Podman ps", func() {
session.WaitWithDefaultTimeout()
Expect(session.OutputToString()).To(ContainSubstring("0.0.0.0:1000-1006"))
})

It("podman ps sync flag", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
fullCid := session.OutputToString()

result := podmanTest.Podman([]string{"ps", "-q", "--no-trunc", "--sync"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
Expect(result.OutputToStringArray()[0]).To(Equal(fullCid))
})
})

0 comments on commit de75b1a

Please sign in to comment.