Skip to content

fix: probably UB (left shift of neg. val) in ip_tree code#3542

Open
airween wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
airween:v2/iptree
Open

fix: probably UB (left shift of neg. val) in ip_tree code#3542
airween wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
airween:v2/iptree

Conversation

@airween
Copy link
Copy Markdown
Member

@airween airween commented Apr 12, 2026

what

This PR fixes a possible undefined behavior (UB) in IP TREE during the execution of @ipMatch.

why

See #3541 for details - same changes for v2.

references

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses potential undefined behavior in the IP tree bitmask generation used during @ipMatch, by avoiding a left-shift of a negative value.

Changes:

  • Update SHIFT_LEFT_MASK(x) to build the mask by left-shifting an unsigned all-ones value instead of (-1) << x.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@airween airween added the 2.x Related to ModSecurity version 2.x label Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Related to ModSecurity version 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants