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

improve strlcpy handling for newer glibc & musl #248

Open
robbat2 opened this issue Dec 31, 2024 · 4 comments · May be fixed by #256
Open

improve strlcpy handling for newer glibc & musl #248

robbat2 opened this issue Dec 31, 2024 · 4 comments · May be fixed by #256

Comments

@robbat2
Copy link
Member

robbat2 commented Dec 31, 2024

Distro bug https://bugs.gentoo.org/show_bug.cgi?id=947276

Make configure check libc (glibc >= 2.38, musl) for strlcpy, with fallback to libbsd.

@angus19
Copy link

angus19 commented Jan 2, 2025

Meet same fatal error during cross compiling and there could be no bsd library in such scenario.

In file included from log.c:16:
includes.h:30:10: fatal error: bsd/string.h: No such file or directory
30 | #include <bsd/string.h> // strlcpy
| ^~~~~~~~~~~~~~
compilation terminated.

@robbat2
Copy link
Member Author

robbat2 commented Jan 3, 2025

Meet same fatal error during cross compiling and there could be no bsd library in such scenario.
You can cross-compile libbsd quite fine; but that's a good reason as well to improve here and support strlcpy from new glibc & musl.

Patches welcome - likely should test libc for strlcpy, and then fall back to libbsd

robbat2 added a commit that referenced this issue Jan 3, 2025
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Fixes: #248
@robbat2 robbat2 linked a pull request Jan 3, 2025 that will close this issue
@angus19
Copy link

angus19 commented Jan 3, 2025

What about including strlcpy.c - the source file and compiling/using it when strlcpy cannot be found from libc or no libbsd is installed? This is an idea. My knowledge to patch files associated with ./configure is limited for now.
Also, it looks like we have to modify includes.h to not add #include <bsd/string.h> if strlcpy can be found from libc or the strlcpy.c is really included.

@robbat2
Copy link
Member Author

robbat2 commented Jan 3, 2025

I think that is likely a good further improvement on top of my existing PR; hoping to have that merged for now.
https://github.com/openbsd/src/blob/master/lib/libc/string/strlcpy.c

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

Successfully merging a pull request may close this issue.

2 participants