IIS: fix Content-Length formatting (correct printf specifier + full buffer size) - #3620
IIS: fix Content-Length formatting (correct printf specifier + full buffer size)#3620A13501350 wants to merge 1 commit into
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 |
|




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.