[asan] Reify ErrorStringFunctionSizeOverflow
Summary: Continuing implementation mentioned in this thread: http://lists.llvm.org/pipermail/llvm-dev/2016-July/101933.html Reviewers: kcc, eugenis, vitalybuka Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D24394 llvm-svn: 281444
This commit is contained in:
parent
7a196b9913
commit
36229e96bc
|
@ -209,4 +209,16 @@ void ErrorStringFunctionMemoryRangesOverlap::Print() {
|
||||||
ReportErrorSummary(bug_type, stack);
|
ReportErrorSummary(bug_type, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ErrorStringFunctionSizeOverflow::Print() {
|
||||||
|
Decorator d;
|
||||||
|
Printf("%s", d.Warning());
|
||||||
|
const char *bug_type = "negative-size-param";
|
||||||
|
Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size);
|
||||||
|
Printf("%s", d.EndWarning());
|
||||||
|
scariness.Print();
|
||||||
|
stack->Print();
|
||||||
|
addr_description.Print();
|
||||||
|
ReportErrorSummary(bug_type, stack);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace __asan
|
} // namespace __asan
|
||||||
|
|
|
@ -221,6 +221,26 @@ struct ErrorStringFunctionMemoryRangesOverlap : ErrorBase {
|
||||||
void Print();
|
void Print();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ErrorStringFunctionSizeOverflow : ErrorBase {
|
||||||
|
// ErrorStringFunctionSizeOverflow doesn't own the stack trace.
|
||||||
|
const BufferedStackTrace *stack;
|
||||||
|
AddressDescription addr_description;
|
||||||
|
uptr size;
|
||||||
|
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
|
||||||
|
// constructor
|
||||||
|
ErrorStringFunctionSizeOverflow() = default;
|
||||||
|
ErrorStringFunctionSizeOverflow(u32 tid, BufferedStackTrace *stack_,
|
||||||
|
uptr addr, uptr size_)
|
||||||
|
: ErrorBase(tid),
|
||||||
|
stack(stack_),
|
||||||
|
addr_description(addr, /*shouldLockThreadRegistry=*/false),
|
||||||
|
size(size_) {
|
||||||
|
scariness.Clear();
|
||||||
|
scariness.Scare(10, "negative-size-param");
|
||||||
|
}
|
||||||
|
void Print();
|
||||||
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
|
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
|
||||||
macro(StackOverflow) \
|
macro(StackOverflow) \
|
||||||
|
@ -231,7 +251,8 @@ struct ErrorStringFunctionMemoryRangesOverlap : ErrorBase {
|
||||||
macro(AllocTypeMismatch) \
|
macro(AllocTypeMismatch) \
|
||||||
macro(MallocUsableSizeNotOwned) \
|
macro(MallocUsableSizeNotOwned) \
|
||||||
macro(SanitizerGetAllocatedSizeNotOwned) \
|
macro(SanitizerGetAllocatedSizeNotOwned) \
|
||||||
macro(StringFunctionMemoryRangesOverlap)
|
macro(StringFunctionMemoryRangesOverlap) \
|
||||||
|
macro(StringFunctionSizeOverflow)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
|
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
|
||||||
|
|
|
@ -391,15 +391,9 @@ void ReportStringFunctionMemoryRangesOverlap(const char *function,
|
||||||
void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
|
void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
|
||||||
BufferedStackTrace *stack) {
|
BufferedStackTrace *stack) {
|
||||||
ScopedInErrorReport in_report;
|
ScopedInErrorReport in_report;
|
||||||
Decorator d;
|
ErrorStringFunctionSizeOverflow error(GetCurrentTidOrInvalid(), stack, offset,
|
||||||
const char *bug_type = "negative-size-param";
|
size);
|
||||||
Printf("%s", d.Warning());
|
in_report.ReportError(error);
|
||||||
Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size);
|
|
||||||
Printf("%s", d.EndWarning());
|
|
||||||
ScarinessScore::PrintSimple(10, bug_type);
|
|
||||||
stack->Print();
|
|
||||||
PrintAddressDescription(offset, size, bug_type);
|
|
||||||
ReportErrorSummary(bug_type, stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
|
void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
|
||||||
|
|
Loading…
Reference in New Issue