-
Notifications
You must be signed in to change notification settings - Fork 288
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
implement internal strlcpy to replace the strncpy #620
base: main
Are you sure you want to change the base?
Conversation
@wyr-7, @tomi-font, |
The strlcpy() function has only recently become available in glibc. To ensure compatibility with legacy libc versions, this commit implements an internal version of strlcpy(). The function has been adapted from the FreeBSD implementation to fit our needs. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit c7c85bcfeb4f2c1be772efea8a889aa796d1a7c1) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit e83acc98ad18f27bd1c12de808aaed84a0091791) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]>
@@ -0,0 +1 @@ | |||
collect (PROJECT_LIB_SOURCES string.c) |
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.
many RTOS support strlcpy need some method to remove string.c or strlcpy from build.
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.
Do you see a potential failure in not using this RTOS strlcpy implementation?
perhaps defining is a weak function would answer to your concern?
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.
Do you see a potential failure in not using this RTOS strlcpy implementation?
the link will report the multiple instance error if RTOS provide one implementation.
perhaps defining is a weak function would answer to your concern?
Yes, it's better.
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.
weak attribute added
The strlcpy() function has only recently become available in glibc. To ensure compatibility with legacy libc versions, this commit implements an internal version of strlcpy(). The function has been adapted from the FreeBSD implementation to fit our needs. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit c7c85bcfeb4f2c1be772efea8a889aa796d1a7c1) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit e83acc98ad18f27bd1c12de808aaed84a0091791) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
The strlcpy() function has only recently become available in glibc. To ensure compatibility with legacy libc versions, this commit implements an internal version of strlcpy(). The function has been adapted from the FreeBSD implementation to fit our needs. Signed-off-by: Arnaud Pouliquen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]>
The strlcpy() function has only recently become available in glibc. To ensure compatibility with legacy libc versions, this commit implements an internal version of strlcpy(). The function has been adapted from the FreeBSD implementation to fit our needs. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit c7c85bcfeb4f2c1be772efea8a889aa796d1a7c1) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit e83acc98ad18f27bd1c12de808aaed84a0091791) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
The strncpy function does not ensure that the destination string is null-terminated. To address this issue, replace strncpy with the internal strlcpy function, which guarantees null-termination of the destination string. Note: (void)strlcpy(...) indicates that the return value is intentionally ignored. Signed-off-by: Arnaud Pouliquen <[email protected]> (cherry picked from commit b1606070c9109ac581e1aa8dcff2871d0207e839) Upstream PR: OpenAMP/open-amp#620 Signed-off-by: Tomi Fontanilles <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
Origin: OpenAMP/open-amp#620 Commits: e233473d14654f08468595ad0dbe8f7e58acf267 8591566382d055acd33f9d23e6826a8a4b0a1881 1aecdc737d463b4ff1ece36847f4f2e68d4ffe4a Status: Cherry pick PR that fixes the `stringop-truncation` compilation errors due to former usage of `strncpy()`. Signed-off-by: Tomi Fontanilles <[email protected]>
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.
This looks good to go.
Compiler complain aboiut the use of strncpy that is not safe.
Already 3 PRs propose a fix of the issue:
As strlcpy seems to have been recently integrated into glibc, implement an internal copy for legacy support. This copy should replace the weak function implemented by the glibc.