[compiler-rt] r324091 - Correct the return value of strlcat(3) in the interceptor
Kamil Rytarowski via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 05:56:52 PST 2018
Author: kamil
Date: Fri Feb 2 05:56:52 2018
New Revision: 324091
URL: http://llvm.org/viewvc/llvm-project?rev=324091&view=rev
Log:
Correct the return value of strlcat(3) in the interceptor
Late fix for SVN r. 324034
Add new interceptors: strlcpy(3) and strlcat(3)
There was forgotten an addition of len to the return value.
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=324091&r1=324090&r2=324091&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Fri Feb 2 05:56:52 2018
@@ -6741,16 +6741,15 @@ INTERCEPTOR(SIZE_T, strlcpy, char *dst,
INTERCEPTOR(SIZE_T, strlcat, char *dst, char *src, SIZE_T size) {
void *ctx;
+ SIZE_T len = 0;
COMMON_INTERCEPTOR_ENTER(ctx, strlcat, dst, src, size);
// src is checked in the strlcpy() interceptor
if (dst) {
- SIZE_T len = REAL(strnlen)(dst, size);
+ len = REAL(strnlen)(dst, size);
COMMON_INTERCEPTOR_READ_STRING(ctx, dst, Min(len, size - 1) + 1);
- // Reuse the rest of the code in the strlcpy() interceptor
- dst += len;
- size -= len;
}
- return WRAP(strlcpy)(dst, src, size);
+ // Reuse the rest of the code in the strlcpy() interceptor
+ return WRAP(strlcpy)(dst + len, src, size - len) + len;
}
#define INIT_STRLCPY \
COMMON_INTERCEPT_FUNCTION(strlcpy); \
More information about the llvm-commits
mailing list