Skip to content
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

Proposed fix to issue #77 Build Fail on Fedora #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

n7ekb
Copy link

@n7ekb n7ekb commented Apr 20, 2024

(#77)

Provides BSD strnstr() function if not defined by build environment's C library.

(OpenRTX#77)

Provides BSD strnstr() function if not defined by build
environment's C library.
@ec1oud
Copy link

ec1oud commented Sep 6, 2024

IMO strnstr(haystack, needle, strlen(haystack)) is quite silly. strstr() would stop when it finds a null terminator. There is no point in scanning the string first to find the null terminator, and then telling strnstr where to stop while it scans it again. Just use strstr(), which is more portable in the first place.

It may be true that strnstr() is "safer" (prevent buffer overrun in case the null terminator is missing or got overwritten due to some other bug), but then you give a constant: the maximum limit for the string size, such as the size of a fixed buffer into which it is stored. And yeah for some reason libc doesn't include strnstr().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants