[msan] Fix a very unfortunate typo in origin copying.
It was causing randomly missing origins. llvm-svn: 194036
This commit is contained in:
parent
bb3a9b74e7
commit
1c8c3fe4b4
|
@ -1348,7 +1348,7 @@ u32 get_origin_if_poisoned(uptr a, uptr size) {
|
|||
unsigned char *s = (unsigned char *)MEM_TO_SHADOW(a);
|
||||
for (uptr i = 0; i < size; ++i)
|
||||
if (s[i])
|
||||
return *(uptr *)SHADOW_TO_ORIGIN((s + i) & ~3UL);
|
||||
return *(u32 *)SHADOW_TO_ORIGIN((s + i) & ~3UL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ void __msan_copy_origin(void *dst, const void *src, uptr size) {
|
|||
if (beg < d) {
|
||||
u32 o = get_origin_if_poisoned(beg, d - beg);
|
||||
if (o)
|
||||
*(uptr *)MEM_TO_ORIGIN(beg) = o;
|
||||
*(u32 *)MEM_TO_ORIGIN(beg) = o;
|
||||
beg += 4;
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1370,7 @@ void __msan_copy_origin(void *dst, const void *src, uptr size) {
|
|||
if (end > d + size) {
|
||||
u32 o = get_origin_if_poisoned(d + size, end - d - size);
|
||||
if (o)
|
||||
*(uptr *)MEM_TO_ORIGIN(end - 4) = o;
|
||||
*(u32 *)MEM_TO_ORIGIN(end - 4) = o;
|
||||
end -= 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -1300,8 +1300,8 @@ void TestUnalignedMemcpy(int left, int right, bool src_is_aligned) {
|
|||
}
|
||||
|
||||
TEST(MemorySanitizer, memcpy_unaligned) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
TestUnalignedMemcpy(i, j, true);
|
||||
TestUnalignedMemcpy(i, j, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue