Repository navigation
fix: pass and receive the long values libcurl expects - #2
Merged
Merged
Conversation
curl_easy_getinfo(CURLINFO_RESPONSE_CODE) writes a long, but received the address of the int m_iResponseStatusCode. long is 4 bytes on Windows, so this was harmless there. On 64-bit Linux it is 8 bytes, and the upper half overwrote the pointer of the adjacent std::string m_ResponseErrorMessage, so destroying any finished request crashed. The code is now read into a long and then stored. The integer curl_easy_setopt options (NOSIGNAL, timeouts, POSTFIELDSIZE, SSL_VERIFYPEER/HOST) also take a long and were passed int or size_t through the variadic call; they now pass long. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
curl_easy_getinfo(CURLINFO_RESPONSE_CODE)writes along, butFinalizePayloadpassed the address of theintm_iResponseStatusCode.longis 4 bytes on Windows (LLP64), so Windows was unaffected.std::string m_ResponseErrorMessage, which sits at offset 16 right after theintat offset 12.RunFramewhile being destroyed. gdb shows the string's pointer changing from0x5555555c99a0to0x555500000000across the call, while the status code itself reads 200.Changes in
src/UtilHTTPClient_libcurl.cpp:longand then stored inm_iResponseStatusCode.curl_easy_setoptoptions also take alongand were passedint(1,60000,secs * 1000) orsize_t(payloadSize) through the variadic call. They now passlong:NOSIGNAL,CONNECTTIMEOUT_MS,TIMEOUT_MS,POSTFIELDSIZE,SSL_VERIFYPEERandSSL_VERIFYHOST.Values and behavior on Windows are unchanged.
Test plan
Sys_LoadModule,CreateAsyncStreamRequest,AddToRequestPool,Send, thenRunFrameuntil completion, against a local HTTP server.IsResponseError.~CUtilHTTPResponse.cmake --build build/format --target format-check(clang-format 23.1.3): 4 files, 0 with differences.🤖 Generated with Claude Code