[compiler-rt] [msan] Support prctl PR_GET_NAME call (PR #98951)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 18:55:37 PDT 2024
================
@@ -1264,7 +1265,18 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
internal_strncpy(buff, (char *)arg2, 15);
buff[15] = 0;
COMMON_INTERCEPTOR_SET_THREAD_NAME(ctx, buff);
- } else if (res != -1 && option == PR_SCHED_CORE && arg2 == PR_SCHED_CORE_GET) {
+ } else if (res != 1 && option == PR_GET_NAME) {
+ unsigned long null_index = 0;
+ char *name = (char *)arg2;
+ while (null_index < 16 && name[null_index]) {
+ ++null_index;
+ }
+ if (null_index > 15) {
+ null_index = 15;
+ }
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)arg2, null_index + 1);
----------------
vitalybuka wrote:
`null_index` -> `internal_strnlen`
but actually just:
`null_index` -> `internal_strlen`
Because on success it must be null-terminated string anyway.
https://github.com/llvm/llvm-project/pull/98951
More information about the llvm-commits
mailing list