minor change: Utilize strlcpy and strlcat instead of strcpy and strcat#6963
minor change: Utilize strlcpy and strlcat instead of strcpy and strcat#6963gemmaro wants to merge 3 commits into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Thank you for the patch, and for caring about bounded string operations. The intent is good, but I cannot merge this as it stands, because These two functions are BSD extensions, not part of standard C. They exist on the BSDs and macOS, on musl, and on glibc only since 2.38 (2023). They are absent on older glibc (for example Ubuntu 22.04 ships glibc 2.35), on MSVC, usually on MinGW's msvcrt, and on many embedded libcs. mruby explicitly supports embedded targets, so we cannot assume the C library provides them. This is not only a link-time issue. mruby compiles C with To take this improvement, mruby first needs its own portable I would be happy to take a revised version along those lines. Thanks again. |
* include/mruby/common.h (MRB_STRLCPY, MRB_STRLCAT): Add a macros.
|
Thank you for the review! Reference links for the conditionals (brief notes in comments):
|
This changeset replaces
strcpywithstrlcpyandstrcatwithstrlcat.These new functions is size-bounded and eliminate warnings like this (on OpenBSD, for instance):
Related issues: #383 #4675
Thank you,