summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmily Trau <emily@downunderctf.com>2023-06-04 16:49:03 -0700
committerAndreas Kling <kling@serenityos.org>2023-06-05 06:55:54 +0200
commit04b06afd39f7a2600e5c9b4e5db3e2030ef8c755 (patch)
treeae5225f93edb68f926694cb6309d20ada34a28ff
parent7f6a49c08560863a99ff80f84ba346a652f792d5 (diff)
downloadserenity-04b06afd39f7a2600e5c9b4e5db3e2030ef8c755.zip
LibC: Fix memmem signature compliance
-rw-r--r--Userland/Libraries/LibC/string.cpp5
-rw-r--r--Userland/Libraries/LibC/string.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibC/string.cpp b/Userland/Libraries/LibC/string.cpp
index 7e31d1f053..baed73c585 100644
--- a/Userland/Libraries/LibC/string.cpp
+++ b/Userland/Libraries/LibC/string.cpp
@@ -175,9 +175,10 @@ void* memmove(void* dest, void const* src, size_t n)
return dest;
}
-void const* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length)
+// https://linux.die.net/man/3/memmem (GNU extension)
+void* memmem(void const* haystack, size_t haystack_length, void const* needle, size_t needle_length)
{
- return AK::memmem(haystack, haystack_length, needle, needle_length);
+ return const_cast<void*>(AK::memmem(haystack, haystack_length, needle, needle_length));
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcpy.html
diff --git a/Userland/Libraries/LibC/string.h b/Userland/Libraries/LibC/string.h
index ba9787d4a8..8a1b6b631c 100644
--- a/Userland/Libraries/LibC/string.h
+++ b/Userland/Libraries/LibC/string.h
@@ -28,7 +28,7 @@ int timingsafe_memcmp(void const*, void const*, size_t);
void* memcpy(void*, void const*, size_t);
void* memmove(void*, void const*, size_t);
void* memchr(void const*, int c, size_t);
-void const* memmem(void const* haystack, size_t, void const* needle, size_t);
+void* memmem(void const* haystack, size_t, void const* needle, size_t);
void* memset(void*, int, size_t);
void explicit_bzero(void*, size_t) __attribute__((nonnull(1)));