confenv: fix possible crash

This commit is contained in:
aler9 2020-10-14 09:48:54 +02:00
parent e724c3ba1e
commit 14efc103ba

View File

@ -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{}