fix panic when passing empty environment

Docker-DCO-1.1-Signed-off-by: Sridhar Ratnakumar <github@srid.name> (github: srid)
This commit is contained in:
Sridhar Ratnakumar 2014-05-15 21:36:15 -07:00
parent 15e734a277
commit d636e8aa0a
1 changed files with 3 additions and 0 deletions

View File

@ -152,6 +152,9 @@ func LoadContainerEnvironment(container *libcontainer.Container) error {
os.Clearenv() os.Clearenv()
for _, pair := range container.Env { for _, pair := range container.Env {
p := strings.SplitN(pair, "=", 2) 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 { if err := os.Setenv(p[0], p[1]); err != nil {
return err return err
} }