Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments remain, and the requested fixes are addressed.
Pull request overview
Fixes IIS Content-Length generation for large responses by correcting format specifiers and buffer sizing.
Changes:
- Uses
%lluforULONGLONGvalues. - Uses
%ufor unsigned lengths. - Passes the full destination buffer size.
File summaries
| File | Description |
|---|---|
iis/mymodule.cpp |
Corrects all three Content-Length formatting call sites. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi @A13501350, thank you for this PR! Could you check SonarCloud issues, and consider to change the suggestions? |
|
Hi @airween, thank you for the review. The warning is about legacy code, unrelated to this fix. I'd like to keep the change minimal; unless there's a large-scale refactoring in the future, fixing it now won't help. |
Ah, sorry, now I see (I just saw the same commit hash on Sonar's page that you added on GH, but didn't realize you changed the other part in the line). Sorry, I'll accept those issues. |

Summary
Fixes the
Content-Lengthheader value being corrupted/truncated in the IIS module when ModSecurity has to synthesize it (only-response, non-chunked case).Two defects were fixed in
iis/mymodule.cpp:ulTotalLengthis aULONGLONG, but was printed with"%d"(32-bitint).printfonly consumed the low 32 bits, producing a wrong header for response bodies larger than ~2 GiB. Now uses"%llu".unsigned intlengthwith"%d"; changed to"%u".StringCchPrintfA'scchDestwas passed assizeof(szLength)/sizeof(CHAR) - 1(20), which can only hold 19 digits + null and would truncate a 20-digit 64-bit value. Now passes the full buffer size (21, which includes the null terminator).Fixes
Closes #3619
Changed locations
iis/mymodule.cpp:644—ulTotalLength(ULONGLONG) ->"%llu"iis/mymodule.cpp:1142—length(unsigned int) ->"%u"iis/mymodule.cpp:1230—length(unsigned int) ->"%u"All three now pass
sizeof(szLength) / sizeof(CHAR)as the destination size.