Skip to content

Fix Cookie::stricmp to safely lowercase signed chars#2502

Open
Kushan20070126 wants to merge 1 commit intodrogonframework:masterfrom
Kushan20070126:master
Open

Fix Cookie::stricmp to safely lowercase signed chars#2502
Kushan20070126 wants to merge 1 commit intodrogonframework:masterfrom
Kushan20070126:master

Conversation

@Kushan20070126
Copy link
Copy Markdown

@Kushan20070126 Kushan20070126 commented Apr 22, 2026

Fix undefined behavior in cookie SameSite case-insensitive comparison.

Cookie::stricmp used tolower(str1[idx]) directly on char.
When char is signed and contains non-ASCII byte values, calling tolower this way is undefined behavior.

Cast each character to unsigned char before passing it to std::tolower, then cast back to char for comparison.

This makes SameSite string comparison standards-compliant and safe across platforms/char signedness, with no behavior change for normal ASCII inputs.

  • Built unittest target.
  • Ran: ./build/lib/tests/unittest -r CookieTest -s
  • Result: All tests passed (12 assertions, 1 test case).
  • Minimal, targeted change in cookie comparison logic only.
  • No API changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant