Conversation
Fix snprintf size argument in sdigest.h to avoid _FORTIFY_SOURCE abort in eic_cuda container as described in #213
Contributor
There was a problem hiding this comment.
Cpp-linter Review
Used clang-format v20.1.2
Click here for the full clang-format patch
diff --git a/sysrap/sdigest.h b/sysrap/sdigest.h
index 0ac1147..e7275fc 100644
--- a/sysrap/sdigest.h
+++ b/sysrap/sdigest.h
@@ -312 +312,2 @@ inline std::string sdigest::DescRaw( unsigned char* digest16 )
- for (int n = 0; n < 16; ++n) std::snprintf( &buf[2*n], 3, "%02x", (unsigned int)digest16[n]) ;
+ for (int n = 0; n < 16; ++n)
+ std::snprintf(&buf[2 * n], 3, "%02x", (unsigned int)digest16[n]);
@@ -326 +327,2 @@ inline std::string sdigest::Finalize(MD5_CTX& c) // static
- for (int n = 0; n < 16; ++n) std::snprintf( &buf[2*n], 3, "%02x", (unsigned int)digest[n]) ;
+ for (int n = 0; n < 16; ++n)
+ std::snprintf(&buf[2 * n], 3, "%02x", (unsigned int)digest[n]);
Have any feedback or feature suggestions? Share it here.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an _FORTIFY_SOURCE runtime abort by correcting the std::snprintf size argument used when formatting MD5 digests into a 32-character hex string in the header-only sdigest implementation (per issue #213).
Changes:
- Adjust
sdigest::DescRaw()to use a per-iteration buffer size of3bytes (2 hex chars + null) instead of the full buffer length. - Adjust
sdigest::Finalize()similarly to avoid passing an oversizedsnprintflength for sub-slices of the output buffer.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
LGTM. So, do you intend to propose this upstream? |
Contributor
Author
|
Yes, I think it is useful for everybody. |
plexoos
approved these changes
Mar 6, 2026
Member
|
Okay, looking forward to an upstream PR for this change. Otherwise, it may be overwritten in the next sync. |
Contributor
Author
|
Opened PR upstream: simoncblyth/opticks#10 |
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.
Fix snprintf size argument in sdigest.h to avoid _FORTIFY_SOURCE abort in eic_cuda container as described in #213