[clang] [clang][StaticAnalyzer] adding timingasafe* api calls interception. (PR #76414)
David CARLIER via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 26 14:25:47 PST 2023
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/76414
timingsafe_bcmp and timingsafe_memcmp have the same signature as their counterparts.
>From eacd951c068cdc25b025a4234bc34e846a3676b1 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Tue, 26 Dec 2023 22:22:32 +0000
Subject: [PATCH] [clang][StaticAnalyzer] adding timingasafe* api calls
interception.
timingsafe_bcmp and timingsafe_memcmp have the same signature
as their counterparts.
---
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 31f5b03dcdeba8..ee51bc5c10a126 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -134,6 +134,8 @@ class CStringChecker : public Checker< eval::Call,
std::bind(&CStringChecker::evalMempcpy, _1, _2, _3, CK_Wide)},
{{CDF_MaybeBuiltin, {"memcmp"}, 3},
std::bind(&CStringChecker::evalMemcmp, _1, _2, _3, CK_Regular)},
+ {{CDF_MaybeBuiltin, {"timingsafe_memcmp"}, 3},
+ std::bind(&CStringChecker::evalMemcmp, _1, _2, _3, CK_Regular)},
{{CDF_MaybeBuiltin, {"wmemcmp"}, 3},
std::bind(&CStringChecker::evalMemcmp, _1, _2, _3, CK_Wide)},
{{CDF_MaybeBuiltin, {"memmove"}, 3},
@@ -162,6 +164,8 @@ class CStringChecker : public Checker< eval::Call,
{{CDF_MaybeBuiltin, {"bcopy"}, 3}, &CStringChecker::evalBcopy},
{{CDF_MaybeBuiltin, {"bcmp"}, 3},
std::bind(&CStringChecker::evalMemcmp, _1, _2, _3, CK_Regular)},
+ {{CDF_MaybeBuiltin, {"timingsafe_bcmp"}, 3},
+ std::bind(&CStringChecker::evalMemcmp, _1, _2, _3, CK_Regular)},
{{CDF_MaybeBuiltin, {"bzero"}, 2}, &CStringChecker::evalBzero},
{{CDF_MaybeBuiltin, {"explicit_bzero"}, 2}, &CStringChecker::evalBzero},
{{CDF_MaybeBuiltin, {"sprintf"}, 2}, &CStringChecker::evalSprintf},
More information about the cfe-commits
mailing list