From 18a7cee3c73574717573f58025cf99d6b9af6da2 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Thu, 15 May 2014 21:36:15 -0700 Subject: [PATCH] fix panic when passing empty environment Docker-DCO-1.1-Signed-off-by: Sridhar Ratnakumar (github: srid) --- libcontainer/nsinit/init.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libcontainer/nsinit/init.go b/libcontainer/nsinit/init.go index 3bbcfcc..af60d73 100644 --- a/libcontainer/nsinit/init.go +++ b/libcontainer/nsinit/init.go @@ -152,6 +152,9 @@ func LoadContainerEnvironment(container *libcontainer.Container) error { os.Clearenv() for _, pair := range container.Env { p := strings.SplitN(pair, "=", 2) + if len(p) < 2 { + return fmt.Errorf("invalid environment '%v'", pair) + } if err := os.Setenv(p[0], p[1]); err != nil { return err }