Fix CWE-134 format string vulnerability in netcomplexity.cc#16
Merged
highperformancecoder merged 2 commits intoJul 18, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix code scanning alert #405
Fix CWE-134 format string vulnerability in netcomplexity.cc
Jul 18, 2026
highperformancecoder
marked this pull request as ready for review
July 18, 2026 07:47
There was a problem hiding this comment.
Pull request overview
Addresses a potential CWE-134 format-string vulnerability by ensuring strerror(errno) is never used as a printf-style format string when constructing ecolab::error (which internally calls vsnprintf).
Changes:
- Replaced
throw error(strerror(errno))withthrow error("%s", strerror(errno))in the affected error paths insrc/netcomplexity.cc. - Ensured
strerror()output is treated as data (string argument) rather than a format string.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int pipes[2]; | ||
| if (pipe(pipes)!=0) | ||
| throw error(strerror(errno)); | ||
| throw error("%s", strerror(errno)); |
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.
strerror(errno)was being passed directly as the format argument to theerrorconstructor (which callsvsnprintf), making it a non-constant format string. Ifstrerror()ever returns a string containing%characters, this triggers undefined behavior and is potentially exploitable (CWE-134).Changes
src/netcomplexity.cc— Replaced 8 occurrences ofthrow error(strerror(errno))with an explicit format string:This ensures the format argument is always a compile-time literal, with
strerror()'s output treated purely as data.This change is