From 14efc103badd4bce088368641ecd6ab5cf719ced Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 14 Oct 2020 09:48:54 +0200 Subject: [PATCH] confenv: fix possible crash --- confenv/confenv.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/confenv/confenv.go b/confenv/confenv.go index cebcd21c..9a95f7ea 100644 --- a/confenv/confenv.go +++ b/confenv/confenv.go @@ -70,12 +70,16 @@ func process(env map[string]string, envKey string, rv reflect.Value) error { case reflect.Map: for k := range env { - if !strings.HasPrefix(k, envKey) { + if !strings.HasPrefix(k, envKey+"_") { continue } - tmp := strings.Split(strings.TrimPrefix(k[len(envKey):], "_"), "_") - mapKey := strings.ToLower(tmp[0]) + tmp := strings.Split(k[len(envKey+"_"):], "_") + mapKey := tmp[0] + if len(mapKey) == 0 { + continue + } + mapKey = strings.ToLower(mapKey) nv := rv.MapIndex(reflect.ValueOf(mapKey)) zero := reflect.Value{}