Skip to content

[sanitizer] Fix few size types in memprof #119114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
4 changes: 2 additions & 2 deletions compiler-rt/lib/asan/asan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, usize size) {
AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_length = MaybeRealStrnlen(from, size);
uptr copy_length = Min(size, from_length + 1);
uptr copy_length = Min<uptr>(size, from_length + 1);
ASAN_READ_RANGE(ctx, from, copy_length);
uptr to_length = internal_strlen(to);
ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
Expand Down Expand Up @@ -622,7 +622,7 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, usize size) {
ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
ASAN_READ_RANGE(ctx, from, from_size);
ASAN_WRITE_RANGE(ctx, to, size);
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/lib/memprof/memprof_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ INTERCEPTOR(char *, strcat, char *to, const char *from) {
return REAL(strcat)(to, from);
}

INTERCEPTOR(char *, strncat, char *to, const char *from, uptr size) {
INTERCEPTOR(char *, strncat, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncat);
ENSURE_MEMPROF_INITED();
uptr from_length = MaybeRealStrnlen(from, size);
uptr copy_length = Min(size, from_length + 1);
uptr copy_length = Min<uptr>(size, from_length + 1);
MEMPROF_READ_RANGE(from, copy_length);
uptr to_length = internal_strlen(to);
MEMPROF_READ_STRING(to, to_length);
Expand Down Expand Up @@ -239,11 +239,11 @@ INTERCEPTOR(char *, __strdup, const char *s) {
return reinterpret_cast<char *>(new_mem);
}

INTERCEPTOR(char *, strncpy, char *to, const char *from, uptr size) {
INTERCEPTOR(char *, strncpy, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncpy);
ENSURE_MEMPROF_INITED();
uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
MEMPROF_READ_RANGE(from, from_size);
MEMPROF_WRITE_RANGE(to, size);
return REAL(strncpy)(to, from, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ extern const short *_tolower_tab_;
uptr copy_length = internal_strnlen(s, size); \
char *new_mem = (char *)WRAP(malloc)(copy_length + 1); \
if (common_flags()->intercept_strndup) { \
COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min(size, copy_length + 1)); \
COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min<uptr>(size, copy_length + 1)); \
} \
if (new_mem) { \
COMMON_INTERCEPTOR_COPY_STRING(ctx, new_mem, s, copy_length); \
Expand Down
Loading