Config: Fix panic on invalid lua-shared-dict. (#12284)

Co-authored-by: AleksaC <aleksacukovic1@gmail.com>
This commit is contained in:
k8s-infra-cherrypick-robot 2024-11-02 15:35:26 -07:00 committed by GitHub
parent b0852ecca9
commit e313ffa544
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -127,8 +127,11 @@ func ReadConfig(src map[string]string) config.Configuration {
delete(conf, luaSharedDictsKey)
lsd := splitAndTrimSpace(val, ",")
for _, v := range lsd {
v = strings.ReplaceAll(v, " ", "")
results := strings.SplitN(v, ":", 2)
results := strings.SplitN(strings.ReplaceAll(v, " ", ""), ":", 2)
if len(results) != 2 {
klog.Errorf("Ignoring poorly formatted Lua dictionary %v", v)
continue
}
dictName := results[0]
size := dictStrToKb(results[1])
if size < 0 {