From 50e24c31ed65a3a7a298a1311685d81d61153c2b Mon Sep 17 00:00:00 2001 From: Marco Sirabella Date: Fri, 3 Nov 2023 12:57:43 -0700 Subject: [PATCH] Unset D_FORTIFY_SOURCE and remove unneeded copied functions Commit 4e2ab71dfe2b1869ec41a3db1fe79387ff46a0fe reverts micropython/micropython@5cf71b55960651fc506df0ac41490f12dd1d63fd which solved micropython/micropython#6046, which I'm seeing again on my gentoo system with D_FORTIFY_HARDENED enabled by default. Unfortunately we can't just revert the revertion because circuitpython enforces prototypes for defined functions, which is why 4e2ab71d was implemented initially. Micropython doesn't suffer from this issue. The implemented fix is to just circumvent D_FORTIFY_SOURCE, a nice side-effect is we can remove the re-implemented functions that were added on the initial `string.h` removal. --- shared/libc/string0.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/shared/libc/string0.c b/shared/libc/string0.c index b0a2620300bfa..5b48e705e53f6 100644 --- a/shared/libc/string0.c +++ b/shared/libc/string0.c @@ -26,6 +26,7 @@ #include #include +#undef _FORTIFY_SOURCE #include #include "py/mpconfig.h" @@ -75,15 +76,6 @@ void *memcpy(void *dst, const void *src, size_t n) { return dst; } -// CIRCUITPY-CHANGE: extern -extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen); -void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) { - if (len > slen) { - return NULL; - } - return memcpy(dest, src, len); -} - void *memmove(void *dest, const void *src, size_t n) { if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) { // need to copy backwards