forked from OSchip/llvm-project
sanitizer: fix crash with textdomain(NULL) interceptor
Summary: The textdomain function accepts a NULL parameter (and should then return the current message domain). Add a check for this and include ASAN tests. Link: https://github.com/google/sanitizers/issues/787 Reviewers: m.guseva, kcc Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D32318 llvm-svn: 300924
This commit is contained in:
parent
9610a26251
commit
b2d291eb9b
|
@ -304,7 +304,7 @@ INTERCEPTOR(SIZE_T, strnlen, const char *s, SIZE_T maxlen) {
|
|||
INTERCEPTOR(char*, textdomain, const char *domainname) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, textdomain, domainname);
|
||||
COMMON_INTERCEPTOR_READ_STRING(ctx, domainname, 0);
|
||||
if (domainname) COMMON_INTERCEPTOR_READ_STRING(ctx, domainname, 0);
|
||||
char *domain = REAL(textdomain)(domainname);
|
||||
if (domain) {
|
||||
COMMON_INTERCEPTOR_INITIALIZE_RANGE(domain, REAL(strlen)(domain) + 1);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: %clang_asan -O0 -g %s -o %t
|
||||
// RUN: %env_asan_opts=strict_string_checks=1 %run %t
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
|
||||
int main() {
|
||||
textdomain(NULL);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue