From 35c02b56ea307d90c5375e35888bf12174ea5148 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 26 Jan 2022 20:12:26 +0200 Subject: [PATCH] server: fix a potential NULL-pointer dereference. Fix a potential NULL-pointer dereference in logging. A (cri-o) client could crash the daemon by sending a CreateContainer request with a NULL Config. Signed-off-by: Krisztian Litkey --- server/container_create.go | 2 +- server/container_create_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/server/container_create.go b/server/container_create.go index 45757c33b86..520efc704e3 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -401,7 +401,7 @@ func setupCapabilities(specgen *generate.Generator, caps *types.Capability, defa // CreateContainer creates a new container in specified PodSandbox func (s *Server) CreateContainer(ctx context.Context, req *types.CreateContainerRequest) (res *types.CreateContainerResponse, retErr error) { - log.Infof(ctx, "Creating container: %s", translateLabelsToDescription(req.Config.Labels)) + log.Infof(ctx, "Creating container: %s", translateLabelsToDescription(req.GetConfig().GetLabels())) sb, err := s.getPodSandboxFromRequest(req.PodSandboxId) if err != nil { diff --git a/server/container_create_test.go b/server/container_create_test.go index fce2374361c..68f3137f117 100644 --- a/server/container_create_test.go +++ b/server/container_create_test.go @@ -114,7 +114,6 @@ var _ = t.Describe("ContainerCreate", func() { response, err := sut.CreateContainer(context.Background(), &types.CreateContainerRequest{ PodSandboxId: testSandbox.ID(), - Config: newContainerConfig(), SandboxConfig: newPodSandboxConfig(), })