Prevent remotely triggerable crash in ODoH config parser

This commit is contained in:
Frank Denis 2021-06-06 01:05:14 +02:00
parent 1cdb71cd7c
commit 92792f0e8b
1 changed files with 3 additions and 0 deletions

View File

@ -63,6 +63,9 @@ func parseODoHTargetConfig(config []byte) (ODoHTargetConfig, error) {
} }
func parseODoHTargetConfigs(configs []byte) ([]ODoHTargetConfig, error) { func parseODoHTargetConfigs(configs []byte) ([]ODoHTargetConfig, error) {
if len(configs) <= 2 {
return nil, fmt.Errorf("No configs")
}
length := binary.BigEndian.Uint16(configs) length := binary.BigEndian.Uint16(configs)
if len(configs) != int(length)+2 { if len(configs) != int(length)+2 {
return nil, fmt.Errorf("Malformed configs") return nil, fmt.Errorf("Malformed configs")