Skip to content

SEC-2576: ArrayIndexOutOfBoundsException in IpAddressMatcher #2790

@spring-projects-issues

Description

@spring-projects-issues

Andreas Woitzick (Migrated from SEC-2576) said:

When dealing with performance issues in our software we looked a little bit deeper in the sources of IpAddressMatcher class. We figured out that the matches-methods will throw an ArrayIndexOutOfBoundsException when the netmask length given at construction time is too large. "Too large" means the netmask byte array is longer the byte array obtained from the ip address.

See attached test class (ArrayIndexOutOfBoundsExceptionTest).

We think to fix these Exception is quite easy, if the byte array for the netmask is determined at construction time and some basic checks are added. (We expect this solution will also perform better if the matches method of an already constructed IpAddressMatcher is called more than once.)

Attached IpAddressMatcher class contains these changes.

For informational purposes we submit the attached IpAddressMatcher2 class with some more performance optimizations (... and API changes). These changes are only seen useful for our special needs.

Best regards
Andreas Woitzick

Metadata

Metadata

Assignees

Labels

in: webAn issue in web modules (web, webmvc)type: bugA general bugtype: jiraAn issue that was migrated from JIRA

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions