Skip to content

Commit ec6ba55

Browse files
author
Andrew Ferraiuolo
committed
Potentially fix google#64
1 parent d219696 commit ec6ba55

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

fuzztest/internal/coverage.cc

+21-22
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
#include <memory>
2424
#include <type_traits>
2525

26-
#include "absl/base/attributes.h"
27-
#include "absl/types/span.h"
2826
#include "./fuzztest/internal/logging.h"
2927
#include "./fuzztest/internal/table_of_recent_compares.h"
28+
#include "absl/base/attributes.h"
29+
#include "absl/types/span.h"
3030

3131
namespace fuzztest::internal {
3232
namespace {
@@ -268,8 +268,7 @@ extern "C" void __sanitizer_cov_8bit_counters_init(uint8_t* start,
268268
// This function should have no external library dependencies to prevent
269269
// accidental coverage instrumentation.
270270
template <int data_size>
271-
ABSL_ATTRIBUTE_ALWAYS_INLINE // To make __builtin_return_address(0) work.
272-
GOOGLEFUZZTEST_NOSANITIZE // To skip arg1 - arg2 overflow.
271+
GOOGLEFUZZTEST_NOSANITIZE // To skip arg1 - arg2 overflow.
273272
void
274273
TraceCmp(uint64_t arg1, uint64_t arg2, uint8_t argsize_bit,
275274
uintptr_t PC =
@@ -288,7 +287,7 @@ ABSL_ATTRIBUTE_ALWAYS_INLINE // To make __builtin_return_address(0) work.
288287

289288
// Use NO_SANITIZE_MEMORY and ADDRESS to skip possible errors on reading buffer.
290289
GOOGLEFUZZTEST_NOSANITIZE
291-
static size_t InternalStrnlen(const char *s, size_t n) {
290+
static size_t InternalStrnlen(const char* s, size_t n) {
292291
size_t len = 0;
293292
while (len < n && s[len]) {
294293
len++;
@@ -297,7 +296,7 @@ static size_t InternalStrnlen(const char *s, size_t n) {
297296
}
298297

299298
GOOGLEFUZZTEST_NOSANITIZE
300-
static size_t InternalStrlen(const char *s1, const char *s2) {
299+
static size_t InternalStrlen(const char* s1, const char* s2) {
301300
size_t len = 0;
302301
while (s1[len] && s2[len]) {
303302
len++;
@@ -306,7 +305,7 @@ static size_t InternalStrlen(const char *s1, const char *s2) {
306305
}
307306

308307
GOOGLEFUZZTEST_NOSANITIZE
309-
static void TraceMemCmp(const uint8_t *s1, const uint8_t *s2, size_t n,
308+
static void TraceMemCmp(const uint8_t* s1, const uint8_t* s2, size_t n,
310309
int result) {
311310
// Non-interesting cases.
312311
if (n <= 1 || result == 0) return;
@@ -345,7 +344,7 @@ void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2) {
345344
}
346345

347346
GOOGLEFUZZTEST_NOSANITIZE
348-
void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {
347+
void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t* Cases) {
349348
uintptr_t PC = reinterpret_cast<uintptr_t>(__builtin_return_address(0));
350349
switch (Cases[0]) {
351350
case 8:
@@ -374,45 +373,45 @@ void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {
374373
}
375374

376375
GOOGLEFUZZTEST_NOSANITIZE
377-
void __sanitizer_weak_hook_strcasecmp(void *, const char *s1, const char *s2,
376+
void __sanitizer_weak_hook_strcasecmp(void*, const char* s1, const char* s2,
378377
int result) {
379378
if (s1 == nullptr || s2 == nullptr) return;
380379
size_t n = InternalStrlen(s1, s2);
381-
TraceMemCmp(reinterpret_cast<const uint8_t *>(s1),
382-
reinterpret_cast<const uint8_t *>(s2), n, result);
380+
TraceMemCmp(reinterpret_cast<const uint8_t*>(s1),
381+
reinterpret_cast<const uint8_t*>(s2), n, result);
383382
}
384383

385384
GOOGLEFUZZTEST_NOSANITIZE
386-
void __sanitizer_weak_hook_memcmp(void *, const void *s1, const void *s2,
385+
void __sanitizer_weak_hook_memcmp(void*, const void* s1, const void* s2,
387386
size_t n, int result) {
388387
if (s1 == nullptr || s2 == nullptr) return;
389-
TraceMemCmp(reinterpret_cast<const uint8_t *>(s1),
390-
reinterpret_cast<const uint8_t *>(s2), n, result);
388+
TraceMemCmp(reinterpret_cast<const uint8_t*>(s1),
389+
reinterpret_cast<const uint8_t*>(s2), n, result);
391390
}
392391

393392
GOOGLEFUZZTEST_NOSANITIZE
394-
void __sanitizer_weak_hook_strncmp(void *, const char *s1, const char *s2,
393+
void __sanitizer_weak_hook_strncmp(void*, const char* s1, const char* s2,
395394
size_t n, int result) {
396395
if (s1 == nullptr || s2 == nullptr) return;
397396
size_t len1 = InternalStrnlen(s1, n);
398397
size_t len2 = InternalStrnlen(s2, n);
399398
n = std::min(std::min(n, len1), len2);
400-
TraceMemCmp(reinterpret_cast<const uint8_t *>(s1),
401-
reinterpret_cast<const uint8_t *>(s2), n, result);
399+
TraceMemCmp(reinterpret_cast<const uint8_t*>(s1),
400+
reinterpret_cast<const uint8_t*>(s2), n, result);
402401
}
403402

404403
GOOGLEFUZZTEST_NOSANITIZE
405-
void __sanitizer_weak_hook_strcmp(void *, const char *s1, const char *s2,
404+
void __sanitizer_weak_hook_strcmp(void*, const char* s1, const char* s2,
406405
int result) {
407406
if (s1 == nullptr || s2 == nullptr) return;
408407
size_t n = InternalStrlen(s1, s2);
409-
TraceMemCmp(reinterpret_cast<const uint8_t *>(s1),
410-
reinterpret_cast<const uint8_t *>(s2), n, result);
408+
TraceMemCmp(reinterpret_cast<const uint8_t*>(s1),
409+
reinterpret_cast<const uint8_t*>(s2), n, result);
411410
}
412411

413412
GOOGLEFUZZTEST_NOSANITIZE
414-
void __sanitizer_weak_hook_strncasecmp(void *caller_pc, const char *s1,
415-
const char *s2, size_t n, int result) {
413+
void __sanitizer_weak_hook_strncasecmp(void* caller_pc, const char* s1,
414+
const char* s2, size_t n, int result) {
416415
if (s1 == nullptr || s2 == nullptr) return;
417416
return __sanitizer_weak_hook_strncmp(caller_pc, s1, s2, n, result);
418417
}

0 commit comments

Comments
 (0)