Repository navigation
prefer 'vsnprintf' to 'vsprintf' - #5561
Merged
Merged
Conversation
Member
Author
|
@guolinke @shiyu1994 could you please help with a review on this one? I think it's fairly small and noncontroversial, and well help LightGBM to maintain compatible with newer releases of the C/C++ toolchain on macOS. |
jameslamb
added a commit
that referenced
this pull request
Dec 6, 2022
jameslamb
added a commit
that referenced
this pull request
Dec 6, 2022
Contributor
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Contributes to #5557.
A recent build of the
M1MacCRAN flavor included the following WARNING:This PR proposes replacing uses of
vsprintf()in LightGBM withvsnprintf().Notes for Reviewers
Looking around GitHub, I can see that other projects have been experiencing this warning when upgrading to macOS Ventura + the newest version of XCode. https://github.com/search?q=%22Due+to+security+concerns+inherent+in+the+design+of+sprintf%22&type=issues. So I don't think this is specific to R or to LightGBM.
References
https://linux.die.net/man/3/vsnprintf describes the benefits of
vsnprintf(). Basically, it is likevsprintf()but requires that you provide an argumentsize_t size, the maximum number of bytes that the function will write to the provided buffer. That added safety prevents use of this function to produce a buffer overflow.I checked, and
vsnprintf_s()is also supported in all of the versions of MSVC LightGBM supports.