From 9d62f4db780d5c86f231d6ee957791f28abc67a7 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Tue, 4 Dec 2018 02:18:18 +0000 Subject: [PATCH] Improve the regerror(3) interceptor The res returned value might differ with REAL(strlen)(errbuf) + 1, as the buffer's value is limited with errbuf_size. Hot fix for D54584. llvm-svn: 348231 --- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index a4c5834..c4f3296 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -7398,8 +7398,8 @@ INTERCEPTOR(SIZE_T, regerror, int errcode, const void *preg, char *errbuf, if (preg) COMMON_INTERCEPTOR_READ_RANGE(ctx, preg, struct_regex_sz); SIZE_T res = REAL(regerror)(errcode, preg, errbuf, errbuf_size); - if (errbuf && res > 0) - COMMON_INTERCEPTOR_WRITE_RANGE(ctx, errbuf, res); + if (errbuf) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, errbuf, REAL(strlen)(errbuf) + 1); return res; } INTERCEPTOR(void, regfree, const void *preg) { -- 2.7.4