[PATCH] D30384: [asan] Add an interceptor for strtok

Manuel Rigger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 16:05:29 PDT 2017


mrigger added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:523
+    if (str != nullptr) {
+      COMMON_INTERCEPTOR_READ_STRING(ctx, str, 1);
+    }
----------------
alekseyshl wrote:
> Shouldn't this also use COMMON_INTERCEPTOR_READ_RANGE?
Good point! It is clearer to use `COMMON_INTERCEPTOR_READ_RANGE` here.


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:529
+      COMMON_INTERCEPTOR_READ_RANGE(ctx, result, REAL(strlen)(result) + 1);
+    }
+    return result;
----------------
alekseyshl wrote:
> If I get the earlier @ygribov's suggestion correctly, we should check the else branch too:
> 
>     if (result != nullptr) {
>       COMMON_INTERCEPTOR_READ_RANGE(ctx, result, REAL(strlen)(result) + 1);
>     } else if (str != nullptr) {
>       // No delimiter were found, it's safe to assume that the entire str was scanned.
>       COMMON_INTERCEPTOR_READ_RANGE(ctx, str, REAL(strlen)(str) + 1);
>     }
Right, I forgot about that case.


https://reviews.llvm.org/D30384





More information about the llvm-commits mailing list