@@ -35,6 +35,8 @@ public class LogFilter {
3535 @ Setter
3636 private Bloom [][] filterBlooms ;
3737
38+ private final int maxTopicDepth = 4 ;
39+ private final int maxSubWidth = 20 ;
3840
3941 public LogFilter () {
4042 }
@@ -58,6 +60,9 @@ public LogFilter(FilterRequest fr) throws JsonRpcInvalidParamsException {
5860 String .format ("invalid address at index %d: %s" , i , s ));
5961 }
6062 }
63+ if (addr .size () > maxSubWidth ) {
64+ throw new JsonRpcInvalidParamsException ("address size should be <= " + maxSubWidth );
65+ }
6166 withContractAddress (addr .toArray (new byte [addr .size ()][]));
6267
6368 } else if (fr .getAddress () != null ) {
@@ -66,8 +71,8 @@ public LogFilter(FilterRequest fr) throws JsonRpcInvalidParamsException {
6671
6772 if (fr .getTopics () != null ) {
6873 //restrict depth of topics, because event has a signature and most 3 indexed parameters
69- if (fr .getTopics ().length > 4 ) {
70- throw new JsonRpcInvalidParamsException ("topics size should be <= 4" );
74+ if (fr .getTopics ().length > maxTopicDepth ) {
75+ throw new JsonRpcInvalidParamsException ("topics size should be <= " + maxTopicDepth );
7176 }
7277 for (Object topic : fr .getTopics ()) {
7378 if (topic == null ) {
@@ -88,6 +93,9 @@ public LogFilter(FilterRequest fr) throws JsonRpcInvalidParamsException {
8893 throw new JsonRpcInvalidParamsException ("invalid topic(s): " + s );
8994 }
9095 }
96+ if (t .size () > maxSubWidth ) {
97+ throw new JsonRpcInvalidParamsException ("topics' width should be <= " + maxSubWidth );
98+ }
9199 withTopic (t .toArray (new byte [t .size ()][]));
92100 } else {
93101 throw new JsonRpcInvalidParamsException ("invalid topic(s)" );
0 commit comments