mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Don't segfault if an image layer has no creation timestamp
It's optional in the specification, and I initially omitted it in the ostree code. Now I've fixed the ostree code to inject a timestamp, but we should clearly avoid segfaulting on this case. Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
@ -94,7 +94,9 @@ func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOption
|
|||||||
func toDomainHistoryLayer(layer *libimage.ImageHistory) entities.ImageHistoryLayer {
|
func toDomainHistoryLayer(layer *libimage.ImageHistory) entities.ImageHistoryLayer {
|
||||||
l := entities.ImageHistoryLayer{}
|
l := entities.ImageHistoryLayer{}
|
||||||
l.ID = layer.ID
|
l.ID = layer.ID
|
||||||
l.Created = *layer.Created
|
if layer.Created != nil {
|
||||||
|
l.Created = *layer.Created
|
||||||
|
}
|
||||||
l.CreatedBy = layer.CreatedBy
|
l.CreatedBy = layer.CreatedBy
|
||||||
copy(l.Tags, layer.Tags)
|
copy(l.Tags, layer.Tags)
|
||||||
l.Size = layer.Size
|
l.Size = layer.Size
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
package abi
|
package abi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/containers/common/libimage"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is really intended to verify what happens with a
|
||||||
|
// nil pointer in layer.Created, but we'll just sanity
|
||||||
|
// check round tripping 42.
|
||||||
|
func TestToDomainHistoryLayer(t *testing.T) {
|
||||||
|
var layer libimage.ImageHistory
|
||||||
|
layer.Size = 42
|
||||||
|
newLayer := toDomainHistoryLayer(&layer)
|
||||||
|
assert.Equal(t, layer.Size, newLayer.Size)
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "context"
|
// "context"
|
||||||
|
Reference in New Issue
Block a user