fix: avoid strnlen() in cs_strndup for Mac OS X 10.5 portability#2889
Open
Scottcjn wants to merge 1 commit intocapstone-engine:nextfrom
Open
fix: avoid strnlen() in cs_strndup for Mac OS X 10.5 portability#2889Scottcjn wants to merge 1 commit intocapstone-engine:nextfrom
Scottcjn wants to merge 1 commit intocapstone-engine:nextfrom
Conversation
Replace strnlen() call with a simple loop to find the bounded string length. strnlen() is POSIX.1-2008 and not available on older platforms like Mac OS X Leopard (10.5). Fixes capstone-engine#2517 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Thanks. Can you please implement it as |
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.
Fixes #2517
The cs_strndup() function in cstest uses strnlen(), which is a POSIX.1-2008 addition and is not available on older platforms -- in our case Mac OS X 10.5 Leopard on PowerPC (we build on a Power Mac G4).
This just replaces the strnlen() call with a plain loop that does the same bounded-length scan. No functional change, just makes it compile on systems that lack strnlen.
Tested building cstest with -DCAPSTONE_BUILD_CSTEST=ON on Leopard.