Unset D_FORTIFY_SOURCE and remove unneeded copied functions

Commit 4e2ab71dfe reverts
micropython/micropython@5cf71b5596
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.
This commit is contained in:
Marco Sirabella 2023-11-03 12:57:43 -07:00
parent 59463683dd
commit 50e24c31ed
1 changed files with 1 additions and 9 deletions

View File

@ -26,6 +26,7 @@
#include <stdint.h>
#include <stddef.h>
#undef _FORTIFY_SOURCE
#include <string.h>
#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