-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add implementation and tests for stpncpy() security wrapper #87
Conversation
This adds support for the optional stpncpy() security wrapper, based on the _FORTIFY_SOURCE setting. By default, it only impacts 10.6 builds, though it can be explicitly enabled on 10.5, albeit less efficiently due to the lack of the compiler builtin. The stpncpy() function is the only one with an optional security wrapper which is also optionally provided by legacy-support. Hence, this is the only addition needed to close the more general ticket. Closes: https://trac.macports.org/ticket/69878 Also fixes a minor comment formatting issue. TESTED: Tested on 10.4-10.5 ppc, 10.4-10.6 i386, 10.5-10.6 ppc (i386 Rosetta), 10.5-12.x x86_64, 11.x-14.x arm64. Passes all tests, including newly added tests for this feature.
@mascguy |
Getting closer now… but just put it in the expected header. |
And….why all the previous drama and arguing? |
If by "expected header" you mean an LS First of all, a header of that name would shadow the SDK copy, so it would need to use The above could be simplified by changing the name of the directory and/or file so that it didn't collide with the SDK The only plausible explanation for why the normal practice is to split the header into two parts is the reduction of clutter in the main header (particularly since the whole security-wrapper thing was an afterthought). But that's actually a mixed blessing, since it splits the information regarding a given function into two separate pieces in two separate files, thus obfuscating the full picture. It's further obfuscated by the fact that the Also note that this whole issue in the LS context is for a grand total of one function, making the "clutter" fairly minimal. So the question is whether to take the simple and more understandable approach of putting everything in one header, or taking the more complicated and more obtuse approach of splitting it in two, just for the questionable goal of kinda sorta mimicking the SDK header layout. Verdict: One file. It might surprise you to learn that I thought about all of this before implementing anything. And just that alone took well over "five minutes". :-) As did explaining it. BTW, Apple added the source code for
Because implementing, debugging, and testing the enhancement, plus implementing, debugging, and testing the test for the enhancement was massively more effort than the one-line addition sufficient to fix the actual bug. That fix is already deployed and working. The whole "five minutes" thing was clearly based on a variant of Weiler's law. @mascguy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from my one question, this looks great! Everything is well-documented, logically organized, etc.
And while I haven't tested with it yet, there are no concerns here.
Anyone else? @kencu and @MarcusCalhoun-Lopez ?
This adds three tests for the proper behavior of the stpncpy() security wrapper, both with and without explictly setting _FORTIFY_SOURCE. TESTED: Tested on 10.4-10.5 ppc, 10.4-10.6 i386, 10.5-10.6 ppc (i386 Rosetta), 10.5-12.x x86_64, 11.x-14.x arm64. Fails in expected cases without the corresponding fix, and passes in all cases with the fix.
@mascguy I have other changes coming soon, so it may not make sense to be in a hurry to update the -devel port. |
I'm fine with either merging ASAP, or deferring until your other changes are done. Up to you! |
Those two things are separate. I'd like to get this PR merged, since there are lexical conflicts with other things I'm working on, but there's no rush for a companion update to the -devel port. Unless someone is really champing at the bit to get security wrappers for C-only uses of |
Got it, I'll go ahead and merge then. Thanks for clarifying! |
See the two commit messages.
Tested on: