diff options
author | Vedant Kumar <vsk@apple.com> | 2017-06-12 18:42:51 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-06-12 18:42:51 +0000 |
commit | 6dbf4274a5275116a79bb23d68d1ac42d54fb266 (patch) | |
tree | 5aaa5a1b1210c24a1b5520b33b8095840fb34b23 /lldb/packages/Python/lldbsuite/test/expression_command/macros/main.cpp | |
parent | 374b41a6aab43830578215cf1337ebb501e7dea7 (diff) | |
download | bcm5719-llvm-6dbf4274a5275116a79bb23d68d1ac42d54fb266.tar.gz bcm5719-llvm-6dbf4274a5275116a79bb23d68d1ac42d54fb266.zip |
[ubsan] Detect invalid unsigned pointer index expression (clang)
Adding an unsigned offset to a base pointer has undefined behavior if
the result of the expression would precede the base. An example from
@regehr:
int foo(char *p, unsigned offset) {
return p + offset >= p; // This may be optimized to '1'.
}
foo(p, -1); // UB.
This patch extends the pointer overflow check in ubsan to detect invalid
unsigned pointer index expressions. It changes the instrumentation to
only permit non-negative offsets in pointer index expressions when all
of the GEP indices are unsigned.
Testing: check-llvm, check-clang run on a stage2, ubsan-instrumented
build.
Differential Revision: https://reviews.llvm.org/D33910
llvm-svn: 305216
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/expression_command/macros/main.cpp')
0 files changed, 0 insertions, 0 deletions