Conversation
When FormatMessage() fails, negotiate_sspi_auth reports the failure
with
SEND2("NA * Windows error: %s", GetLastError());
GetLastError() returns a DWORD, so %s makes printf() -- and debug(),
through SEND2 -- treat the error number as a pointer and read from
it. The helper crashes on this path instead of answering Squid with
NA.
By then GetLastError() no longer holds the error being reported
either: FormatMessage() has replaced it with its own failure code,
ERROR_MR_MID_NOT_FOUND (317). Save the error before calling
FormatMessage(), and report that saved code when Windows has no
message text for it. When text is available, the existing path
still sends it.
Print the number with %lu and cast it to unsigned long. DWORD is
unsigned int on Cygwin, where the SSPI helpers are built, and
unsigned long on MinGW, so no single conversion without a cast fits
both. src/windows_service.cc prints GetLastError() the same way, to
keep the two in sync.
Found building 7.7 on Cygwin, where GCC 14 warns: format '%s' expects
argument of type 'char*', but argument 2 has type 'DWORD'. With this
change the file compiles with no format warnings under -Wall -Wextra
-Wformat=2 on Cygwin, and windows_service.cc's line compiles without
format warnings on MinGW GCC 16 even with -Wformat-signedness.
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.
When FormatMessage() fails, negotiate_sspi_auth reports the failure
with
GetLastError() returns a DWORD, so %s makes printf() -- and debug(),
through SEND2 -- treat the error number as a pointer and read from
it. The helper crashes on this path instead of answering Squid with
NA.
By then GetLastError() no longer holds the error being reported
either: FormatMessage() has replaced it with its own failure code,
ERROR_MR_MID_NOT_FOUND (317). Save the error before calling
FormatMessage(), and report that saved code when Windows has no
message text for it. When text is available, the existing path
still sends it.
Print the number with %lu and cast it to unsigned long. DWORD is
unsigned int on Cygwin, where the SSPI helpers are built, and
unsigned long on MinGW, so no single conversion without a cast fits
both. src/windows_service.cc prints GetLastError() the same way, to
keep the two in sync.
Found building 7.7 on Cygwin, where GCC 14 warns: format '%s' expects
argument of type 'char*', but argument 2 has type 'DWORD'. With this
change the file compiles with no format warnings under -Wall -Wextra
-Wformat=2 on Cygwin, and windows_service.cc's line compiles without
format warnings on MinGW GCC 16 even with -Wformat-signedness.