From 97ea1255ed552525619a9aac2faf4f316923bcde Mon Sep 17 00:00:00 2001 From: Andrey Tsygunka Date: Tue, 7 Feb 2023 10:29:23 +0300 Subject: [PATCH] Fix runc crushes when parsing invalid JSON Signed-off-by: Andrey Tsygunka --- spec.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec.go b/spec.go index 806d2f15f..d03d644e2 100644 --- a/spec.go +++ b/spec.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "errors" "fmt" "os" @@ -126,6 +127,9 @@ func loadSpec(cPath string) (spec *specs.Spec, err error) { if err = json.NewDecoder(cf).Decode(&spec); err != nil { return nil, err } + if spec == nil { + return nil, errors.New("config cannot be null") + } return spec, validateProcessSpec(spec.Process) }