Uh oh!
There was an error while loading. Please reload this page.
fs: fix out-of-bounds write in mkdtemp for long prefixes - #64770
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## main #64770 +/- ##
==========================================
- Coverage 90.14% 90.13% -0.01%
==========================================
Files 744 744 Lines 242518 242519 +1 Branches 45685 45685 ==========================================
- Hits 218611 218599 -12 - Misses 15396 15406 +10 - Partials 8511 8514 +3
🚀 New features to boost your workflow:
|
Uh oh!
There was an error while loading. Please reload this page.
Mkdtemp() allocated the template buffer as `length + strlen("XXXXXX")`,
leaving no room for the terminating NUL byte. For a single-byte prefix
long enough to force the heap allocation path (length + 6 > the
stack-buffer threshold), the terminating NUL was written one byte past
the end of the buffer -- a 1-byte heap-buffer-overflow flagged by
AddressSanitizer.
Allocate room for the terminating NUL, copy the suffix, and use
SetLengthAndZeroTerminate to set the correct length and write the
terminator, following the MaybeStackBuffer paradigm used elsewhere in
this file.
Signed-off-by: frandle331-yh <s1240100@gmail.com>7bcec4a to
a702884Compare
This comment has been minimized.
This comment has been minimized.
frandle331-yh
commented
Jul 28, 2026
It looks like the macOS CI failed due to a timeout in parallel/test-debugger-break, which seems unrelated to my fs.mkdtemp changes (likely a flaky test). |
nodejs-github-bot
commented
Jul 28, 2026
frandle331-yh
commented
Jul 28, 2026
It looks like the CI failed again (node-test-commit, etc.), but I don't have permission to view the Jenkins logs. |
nodejs-github-bot
commented
Aug 9, 2026
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Aug 20, 2026
Landed in 9472421 |
Mkdtemp() allocated the template buffer as `length + strlen("XXXXXX")`,
leaving no room for the terminating NUL byte. For a single-byte prefix
long enough to force the heap allocation path (length + 6 > the
stack-buffer threshold), the terminating NUL was written one byte past
the end of the buffer -- a 1-byte heap-buffer-overflow flagged by
AddressSanitizer.
Allocate room for the terminating NUL, copy the suffix, and use
SetLengthAndZeroTerminate to set the correct length and write the
terminator, following the MaybeStackBuffer paradigm used elsewhere in
this file.
Signed-off-by: frandle331-yh <s1240100@gmail.com>
PR-URL: #64770
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>Mkdtemp() allocated the template buffer as `length + strlen("XXXXXX")`,
leaving no room for the terminating NUL byte. For a single-byte prefix
long enough to force the heap allocation path (length + 6 > the
stack-buffer threshold), the terminating NUL was written one byte past
the end of the buffer -- a 1-byte heap-buffer-overflow flagged by
AddressSanitizer.
Allocate room for the terminating NUL, copy the suffix, and use
SetLengthAndZeroTerminate to set the correct length and write the
terminator, following the MaybeStackBuffer paradigm used elsewhere in
this file.
Signed-off-by: frandle331-yh <s1240100@gmail.com>
PR-URL: #64770
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>Mkdtemp() allocated the template buffer as `length + strlen("XXXXXX")`,
leaving no room for the terminating NUL byte. For a single-byte prefix
long enough to force the heap allocation path (length + 6 > the
stack-buffer threshold), the terminating NUL was written one byte past
the end of the buffer -- a 1-byte heap-buffer-overflow flagged by
AddressSanitizer.
Allocate room for the terminating NUL, copy the suffix, and use
SetLengthAndZeroTerminate to set the correct length and write the
terminator, following the MaybeStackBuffer paradigm used elsewhere in
this file.
Signed-off-by: frandle331-yh <s1240100@gmail.com>
PR-URL: #64770
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Mkdtemp() allocated the template buffer as
length + strlen("XXXXXX"),leaving no room for the terminating NUL byte that snprintf() writes. For
a single-byte prefix long enough to force the heap allocation path
(length + 6 > the stack-buffer threshold), snprintf() wrote the six 'X'
characters plus its NUL one byte past the end of the buffer -- a 1-byte
heap-buffer-overflow flagged by AddressSanitizer.
Allocate one extra byte for the NUL terminator, matching the
+ 1already used by the sibling allocations in the same file.
Signed-off-by: frandle331-yh s1240100@gmail.com