eth/filters: enforce topic-limit early on filter criterias

This commit is contained in:
Martin Holst Swende 2024-04-15 10:43:03 +02:00
parent 3705acd1a9
commit 13f209ff47
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -539,6 +539,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
return errors.New("invalid addresses in query")
}
}
if len(raw.Topics) > maxTopics {
return errExceedMaxTopics
}
// topics is an array consisting of strings and/or arrays of strings.
// JSON null values are converted to common.Hash{} and ignored by the filter manager.
@ -559,6 +562,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
case []interface{}:
// or case e.g. [null, "topic0", "topic1"]
if len(topic) > maxTopics {
return errExceedMaxTopics
}
for _, rawTopic := range topic {
if rawTopic == nil {
// null component, match all