Skip to content

Commit fcb51ec

Browse files
alhijaziAli Hijazi
andauthored
Fix cmplog collection in ASAN builds (#3375)
In `__libafl_targets_cmplog_routines_len` and `__libafl_targets_cmplog_routines_extended_len`, `area_is_valid` was called with `CMPLOG_RTN_LEN` as length instead of the length passed as argument. In ASAN instrumented builds, this leads to an early exit since ASAN would detect the region as poisoned anytime the argument's actual length is less than `CMPLOG_RTN_LEN`. Fix this issue by passing the len argument instead of `CMPLOG_RTN_LEN`. Co-authored-by: Ali Hijazi <[email protected]>
1 parent 462cf2d commit fcb51ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/libafl_targets/src/cmplog.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ void __libafl_targets_cmplog_routines_len(uintptr_t k, const uint8_t *ptr1,
127127
const uint8_t *ptr2, size_t len) {
128128
if (!libafl_cmplog_enabled) { return; }
129129

130-
if (area_is_valid(ptr1, CMPLOG_RTN_LEN) <= 0 ||
131-
area_is_valid(ptr2, CMPLOG_RTN_LEN) <= 0) {
130+
if (area_is_valid(ptr1, len) <= 0 ||
131+
area_is_valid(ptr2, len) <= 0) {
132132
return;
133133
}
134134

@@ -157,8 +157,8 @@ void __libafl_targets_cmplog_routines_extended_len(uintptr_t k, const uint8_t *p
157157
const uint8_t *ptr2, size_t len) {
158158
if (!libafl_cmplog_enabled) { return; }
159159

160-
if ((area_is_valid(ptr1, CMPLOG_RTN_LEN)) <= 0 ||
161-
(area_is_valid(ptr2, CMPLOG_RTN_LEN)) <= 0) {
160+
if ((area_is_valid(ptr1, len)) <= 0 ||
161+
(area_is_valid(ptr2, len)) <= 0) {
162162
return;
163163
}
164164

0 commit comments

Comments
 (0)