From 77e82d8a344c347dd4e849faf725e1afa7059df9 Mon Sep 17 00:00:00 2001 From: AndrewX98 Date: Tue, 30 Dec 2025 12:31:32 +0000 Subject: [PATCH 1/2] added the missing __strlcpy_chk symbol Added __strlcpy_chk function to handle string copy with size checks. --- src/common.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common.cpp b/src/common.cpp index 3f8e1b2..2ef6d95 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -356,6 +356,15 @@ char* shim::__strncpy_chk2(char* dst, const char* src, size_t n, size_t dst_len, return strncpy(dst, src, n); } +size_t shim::__strlcpy_chk(char *dst, const char *src, size_t size, + size_t max_len) { + if (size > max_len) { + fprintf(stderr, "detected copy past buffer size"); + abort(); + } + return bionic::strlcpy(dst, src, size); +} + int shim::sendfile(int src, int dst, bionic::off_t *offset, size_t count) { off_t c = offset ? (off_t)offset : 0; #ifdef __APPLE__ @@ -896,6 +905,7 @@ void shim::add_string_shimmed_symbols(std::vector &list) { {"__strncat_chk", __strncat_chk}, {"__strncpy_chk", __strncpy_chk}, {"__strncpy_chk2", __strncpy_chk2}, + {"__strlcpy_chk", __strlcpy_chk}, {"strlcpy", bionic::strlcpy}, {"strcspn", ::strcspn}, {"strpbrk", (char *(*)(char *, const char *)) ::strpbrk}, From 45378891d7b2d40d77716a768c89422f95339e36 Mon Sep 17 00:00:00 2001 From: AndrewX98 Date: Tue, 30 Dec 2025 12:51:43 +0000 Subject: [PATCH 2/2] Add __strlcpy_chk function declaration --- src/common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common.h b/src/common.h index a53b248..69f6a96 100644 --- a/src/common.h +++ b/src/common.h @@ -128,6 +128,8 @@ namespace shim { char* __strncpy_chk2(char* dst, const char* src, size_t n, size_t dst_len, size_t src_len); + size_t __strlcpy_chk(char *dst, const char *src, size_t size, size_t max_len); + size_t ctype_get_mb_cur_max(); int gettimeofday(bionic::timeval *tv, void *p);