Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -896,6 +905,7 @@ void shim::add_string_shimmed_symbols(std::vector<shim::shimmed_symbol> &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},
Expand Down
2 changes: 2 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down