[compiler-rt] 54d6c11 - [msan] Fix srcaddr handling in recvfrom interceptor.
Evgenii Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 17:29:27 PDT 2020
Author: Evgenii Stepanov
Date: 2020-03-12T17:29:10-07:00
New Revision: 54d6c11a6ca1fc47707d57ea7874d2cfb51ea07d
URL: https://github.com/llvm/llvm-project/commit/54d6c11a6ca1fc47707d57ea7874d2cfb51ea07d
DIFF: https://github.com/llvm/llvm-project/commit/54d6c11a6ca1fc47707d57ea7874d2cfb51ea07d.diff
LOG: [msan] Fix srcaddr handling in recvfrom interceptor.
Recvfrom may receive a 0 byte packet with a non-empty source address.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 454a081cdf92..6daed4a6736c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -6433,12 +6433,11 @@ INTERCEPTOR(SSIZE_T, recvfrom, int fd, void *buf, SIZE_T len, int flags,
if (srcaddr) srcaddr_sz = *addrlen;
(void)srcaddr_sz; // prevent "set but not used" warning
SSIZE_T res = REAL(recvfrom)(fd, buf, len, flags, srcaddr, addrlen);
- if (res > 0) {
+ if (res > 0)
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, Min((SIZE_T)res, len));
- if (srcaddr)
- COMMON_INTERCEPTOR_INITIALIZE_RANGE(srcaddr,
- Min((SIZE_T)*addrlen, srcaddr_sz));
- }
+ if (res >= 0 && srcaddr)
+ COMMON_INTERCEPTOR_INITIALIZE_RANGE(srcaddr,
+ Min((SIZE_T)*addrlen, srcaddr_sz));
return res;
}
#define INIT_RECV_RECVFROM \
More information about the llvm-commits
mailing list