fix(deps) ia32_insn potentially unsafe call to strncat #84
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.
desktop/deps/breakpad/third_party/libdisasm/ia32_insn.c
Lines 226 to 235 in 896565c
Fix the issue need to ensure that the
strncat
function does not write beyond the bounds of theinsn->prefix_string
buffer. This can be achieved by explicitly defining the size of the buffer and ensuring that the third argument tostrncat
accounts for the null-terminator. The calculation should be updated tosizeof(insn->prefix_string) - strlen(insn->prefix_string) - 1
, which reserves space for the null-terminator. Additionally, we should verify thatinsn->prefix_string
is properly initialized and null-terminated before any concatenation operations.Improper Restriction of Operations within the Bounds of a Memory Buffer
The standard library function
strncat
appends a source string to a target string. The third argument defines the maximum number of characters to append and should be less than or equal to the remaining space in the destination buffer. Calls of the formstrncat(dest, src, strlen(dest))
orstrncat(dest, src, sizeof(dest))
set the third argument to the entire size of the destination buffer. Executing a call of this type may cause a buffer overflow unless the buffer is known to be empty. Similarly, calls of the formstrncat(dest, src, sizeof (dest) - strlen (dest))
allow one byte to be written outside thedest
buffer. Buffer overflows can lead to anything from a segmentation fault to a security vulnerability.strncat, strncpy
STR31-C. Guarantee that storage for strings has sufficient space for character data and the null terminator