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

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 14:29:26 PDT 2017


alekseyshl accepted this revision.
alekseyshl added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:523
+    if (str != nullptr) {
+      COMMON_INTERCEPTOR_READ_STRING(ctx, str, 1);
+    }
----------------
Shouldn't this also use COMMON_INTERCEPTOR_READ_RANGE?


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:529
+      COMMON_INTERCEPTOR_READ_RANGE(ctx, result, REAL(strlen)(result) + 1);
+    }
+    return result;
----------------
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);
    }


https://reviews.llvm.org/D30384





More information about the llvm-commits mailing list