casaroli commented on code in PR #22177:
URL: https://github.com/apache/nuttx/pull/22177#discussion_r4665493576
##########
libs/libc/string/lib_strcasestr.c:
##########
@@ -78,7 +78,7 @@ FAR char *strcasestr(FAR const char *str, FAR const char
*substr)
/* Search for the substring */
candidate = str;
- ch = toupper(ch);
+ ch = (char)toupper((unsigned char)ch);
Review Comment:
With a signed plain char (x86, x86_64, the simulator), `ch` is now negative
for a first byte >= 0x80: `(char)toupper(0xe9)` is -23. strcasechr() compares
it with `toupper((unsigned char)ch)`, which is 0..255, so it never matches. On
master `strcasestr("caf\xe9", "\xe9")` finds the byte; with this change it
returns NULL.
Fix: keep the converted value in an int, for example `int uc =
toupper((unsigned char)*substr);`, and pass that to strcasechr().
##########
libs/libc/string/lib_memcmp.c:
##########
@@ -60,3 +60,22 @@ int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
return 0;
}
#endif
+
+#if CONFIG_FORTIFY_SOURCE
+#undef bcmp
+int bcmp(FAR const void *s1, FAR const void *s2, size_t n)
Review Comment:
bcmp() is already a function of libc: libs/libc/string/lib_bcmp.c, built in
every configuration. With CONFIG_FORTIFY_SOURCE > 0 libc.a now has two strong
bcmp() definitions (lib_bcmp.o and lib_memcmp.o). A program that calls bcmp()
and uses this memcmp() pulls both objects and the link fails. qemu-armv8a:knsh
with FORTIFY_SOURCE=1 and without the arm64 memcmp(), a program that calls
bcmp() and memcmp(): "lib_memcmp.c:73: multiple definition of `bcmp'; ...
lib_bcmp.c:44: first defined here". crypto/set_key.c calls bcmp() too.
Fix: drop this bcmp(); lib_bcmp.c already provides it with FORTIFY_SOURCE.
##########
libs/libc/string/lib_flsll.c:
##########
@@ -20,6 +20,12 @@
*
****************************************************************************/
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/compiler.h>
Review Comment:
lib_ffsll.c and lib_flsll.c test no CONFIG_ or compiler macro, so this
include changes no code. The code in the commit message (the `flsll(j)` macro
under `CONFIG_HAVE_LONG_LONG`) is from include/strings.h, which these files do
not include.
Fix: drop the commit, or name the configuration that fails without it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]