@@ -105,7 +105,7 @@ void __libafl_targets_cmplog_instructions(uintptr_t k, uint8_t shape,
105
105
// Very generic afl++ style cmplog instructions callback
106
106
void __libafl_targets_cmplog_instructions_extended (uintptr_t k , uint8_t shape ,
107
107
uint64_t arg1 , uint64_t arg2 ) {
108
- cmplog_instructions_extended_checked (k , shape , arg1 , arg2 , 0 );
108
+ cmplog_instructions_checked_extended (k , shape , arg1 , arg2 , 0 );
109
109
}
110
110
111
111
// Very generic cmplog routines callback
@@ -133,8 +133,43 @@ void __libafl_targets_cmplog_routines_len(uintptr_t k, const uint8_t *ptr1,
133
133
return ;
134
134
}
135
135
136
+ if (len >= CMPLOG_RTN_LEN ) {
137
+ len = CMPLOG_RTN_LEN - 1 ;
138
+ }
139
+
136
140
cmplog_routines_checked (k , ptr1 , ptr2 , len );
137
141
}
142
+
143
+ void __libafl_targets_cmplog_routines_extended (uintptr_t k , const uint8_t * ptr1 ,
144
+ const uint8_t * ptr2 ) {
145
+ if (!libafl_cmplog_enabled ) { return ; }
146
+
147
+ int l1 , l2 ;
148
+ if ((l1 = area_is_valid (ptr1 , CMPLOG_RTN_LEN )) <= 0 ||
149
+ (l2 = area_is_valid (ptr2 , CMPLOG_RTN_LEN )) <= 0 ) {
150
+ return ;
151
+ }
152
+ int len = MIN (l1 , l2 );
153
+
154
+ cmplog_routines_checked_extended (k , ptr1 , ptr2 , len );
155
+ }
156
+
157
+ void __libafl_targets_cmplog_routines_extended_len (uintptr_t k , const uint8_t * ptr1 ,
158
+ const uint8_t * ptr2 , size_t len ) {
159
+ if (!libafl_cmplog_enabled ) { return ; }
160
+
161
+ if ((area_is_valid (ptr1 , CMPLOG_RTN_LEN )) <= 0 ||
162
+ (area_is_valid (ptr2 , CMPLOG_RTN_LEN )) <= 0 ) {
163
+ return ;
164
+ }
165
+
166
+ if (len >= CMPLOG_RTN_LEN ) {
167
+ len = CMPLOG_RTN_LEN - 1 ;
168
+ }
169
+
170
+ cmplog_routines_checked_extended (k , ptr1 , ptr2 , len );
171
+ }
172
+
138
173
/*
139
174
CMPLOG Callback for instructions
140
175
*/
@@ -144,7 +179,7 @@ void __cmplog_ins_hook1_extended(uint8_t arg1, uint8_t arg2, uint8_t attr) {
144
179
k = (k >> 4 ) ^ (k << 8 );
145
180
k &= CMPLOG_MAP_W - 1 ;
146
181
147
- cmplog_instructions_extended_checked (k , 0 , arg1 , arg2 , attr );
182
+ cmplog_instructions_checked_extended (k , 0 , arg1 , arg2 , attr );
148
183
}
149
184
void __cmplog_ins_hook1 (uint8_t arg1 , uint8_t arg2 ) {
150
185
uintptr_t k = RETADDR ;
@@ -159,7 +194,7 @@ void __cmplog_ins_hook2_extended(uint16_t arg1, uint16_t arg2, uint8_t attr) {
159
194
k = (k >> 4 ) ^ (k << 8 );
160
195
k &= CMPLOG_MAP_W - 1 ;
161
196
162
- cmplog_instructions_extended_checked (k , 1 , arg1 , arg2 , attr );
197
+ cmplog_instructions_checked_extended (k , 1 , arg1 , arg2 , attr );
163
198
}
164
199
void __cmplog_ins_hook2 (uint16_t arg1 , uint16_t arg2 ) {
165
200
uintptr_t k = RETADDR ;
@@ -174,7 +209,7 @@ void __cmplog_ins_hook4_extended(uint32_t arg1, uint32_t arg2, uint8_t attr) {
174
209
k = (k >> 4 ) ^ (k << 8 );
175
210
k &= CMPLOG_MAP_W - 1 ;
176
211
177
- cmplog_instructions_extended_checked (k , 3 , arg1 , arg2 , attr );
212
+ cmplog_instructions_checked_extended (k , 3 , arg1 , arg2 , attr );
178
213
}
179
214
void __cmplog_ins_hook4 (uint32_t arg1 , uint32_t arg2 ) {
180
215
uintptr_t k = RETADDR ;
@@ -189,7 +224,7 @@ void __cmplog_ins_hook8_extended(uint64_t arg1, uint64_t arg2, uint8_t attr) {
189
224
k = (k >> 4 ) ^ (k << 8 );
190
225
k &= CMPLOG_MAP_W - 1 ;
191
226
192
- cmplog_instructions_extended_checked (k , 7 , arg1 , arg2 , attr );
227
+ cmplog_instructions_checked_extended (k , 7 , arg1 , arg2 , attr );
193
228
}
194
229
void __cmplog_ins_hook8 (uint64_t arg1 , uint64_t arg2 ) {
195
230
uintptr_t k = RETADDR ;
@@ -206,7 +241,7 @@ void __cmplog_ins_hook16_extended(uint128_t arg1, uint128_t arg2,
206
241
k = (k >> 4 ) ^ (k << 8 );
207
242
k &= CMPLOG_MAP_W - 1 ;
208
243
209
- cmplog_instructions_extended_checked (k , 15 , arg1 , arg2 , attr );
244
+ cmplog_instructions_checked_extended (k , 15 , arg1 , arg2 , attr );
210
245
}
211
246
void __cmplog_ins_hook16 (uint128_t arg1 , uint128_t arg2 ) {
212
247
uintptr_t k = RETADDR ;
@@ -222,7 +257,7 @@ void __cmplog_ins_hookN_extended(uint128_t arg1, uint128_t arg2, uint8_t attr,
222
257
k = (k >> 4 ) ^ (k << 8 );
223
258
k &= CMPLOG_MAP_W - 1 ;
224
259
225
- cmplog_instructions_extended_checked (k , size - 1 , arg1 , arg2 , attr );
260
+ cmplog_instructions_checked_extended (k , size - 1 , arg1 , arg2 , attr );
226
261
}
227
262
void __cmplog_ins_hookN (uint128_t arg1 , uint128_t arg2 , uint8_t size ) {
228
263
uintptr_t k = RETADDR ;
0 commit comments