mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 16:30:49 +02:00
linuxkm/linuxkm_wc_port.h: in my_memmove(), early-return when n == 0 to avoid size_t underflow
The backward-copy branches compute (n - 1) as size_t, which wraps to SIZE_MAX for n == 0 and, with src below dest, drives the loop backward through kernel memory until it oopses; matches glibc / musl / kernel memmove(). Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
This commit is contained in:
@@ -450,6 +450,8 @@
|
||||
#define memset my_memset
|
||||
|
||||
static inline void *my_memmove(void *dest, const void *src, size_t n) {
|
||||
if (n == 0)
|
||||
return dest;
|
||||
if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n)
|
||||
& (uintptr_t)(sizeof(uintptr_t) - 1)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user