[compiler-rt] r348231 - Improve the regerror(3) interceptor

Kamil Rytarowski via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 3 18:18:18 PST 2018


Author: kamil
Date: Mon Dec  3 18:18:18 2018
New Revision: 348231

URL: http://llvm.org/viewvc/llvm-project?rev=348231&view=rev
Log:
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.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=348231&r1=348230&r2=348231&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Dec  3 18:18:18 2018
@@ -7398,8 +7398,8 @@ INTERCEPTOR(SIZE_T, regerror, int errcod
   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) {




More information about the llvm-commits mailing list