Fix CodeQL format-specifier alerts in gumbo/error.c#4
Merged
Conversation
GumboError.v.codepoint is declared as uint64_t in error.h, but gumbo_error_to_string formatted it with %x/%d, which expect unsigned int/int. On platforms where these widths differ, this causes undefined behavior and was flagged by CodeQL (cpp/wrong-type-format-argument). Use the PRIx64/PRId64 macros from <inttypes.h> so the format specifiers match the actual argument width. Fixes CodeQL alerts #1, #2, #3, #4. Co-Authored-By: Claude Opus 4.7 <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
GumboError.v.codepointis declareduint64_tingumbo/error.h, butgumbo_error_to_stringformatted it with%x/%d, which expectunsigned int/int. This is undefined behavior on platforms where those widths differ and was flagged by CodeQL (cpp/wrong-type-format-argument).print_messagecalls to usePRIx64/PRId64from<inttypes.h>so the format specifier matches the argument width.Fixes the following CodeQL alerts on
main:src/libraries/qlitehtml/src/3rdparty/litehtml/src/gumbo/error.c:174src/libraries/qlitehtml/src/3rdparty/litehtml/src/gumbo/error.c:179src/libraries/qlitehtml/src/3rdparty/litehtml/src/gumbo/error.c:189src/libraries/qlitehtml/src/3rdparty/litehtml/src/gumbo/error.c:195See: https://github.com/ArcForges/ArcNotes/security/code-scanning
Test plan
🤖 Generated with Claude Code