mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 10:38:07 +00:00
fix warning, code format
This commit is contained in:
@ -47,14 +47,13 @@
|
|||||||
|
|
||||||
# define alloc_printf(_str...) \
|
# define alloc_printf(_str...) \
|
||||||
({ \
|
({ \
|
||||||
\
|
|
||||||
u8 *_tmp; \
|
u8 *_tmp; \
|
||||||
s32 _len = snprintf(NULL, 0, _str); \
|
s32 _len = snprintf(NULL, 0, _str); \
|
||||||
if (_len < 0) FATAL("Whoa, snprintf() fails?!"); \
|
if (_len < 0) FATAL("Whoa, snprintf() fails?!"); \
|
||||||
_tmp = ck_alloc(_len + 1); \
|
_tmp = ck_alloc(_len + 1); \
|
||||||
snprintf((char *)_tmp, _len + 1, _str); \
|
snprintf((char *)_tmp, _len + 1, _str); \
|
||||||
_tmp; \
|
_tmp; \
|
||||||
\
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Macro to enforce allocation limits as a last-resort defense against
|
/* Macro to enforce allocation limits as a last-resort defense against
|
||||||
@ -62,18 +61,18 @@
|
|||||||
|
|
||||||
# define ALLOC_CHECK_SIZE(_s) \
|
# define ALLOC_CHECK_SIZE(_s) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
if ((_s) > MAX_ALLOC) ABORT("Bad alloc request: %u bytes", (_s)); \
|
if ((_s) > MAX_ALLOC) ABORT("Bad alloc request: %u bytes", (_s)); \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Macro to check malloc() failures and the like. */
|
/* Macro to check malloc() failures and the like. */
|
||||||
|
|
||||||
# define ALLOC_CHECK_RESULT(_r, _s) \
|
# define ALLOC_CHECK_RESULT(_r, _s) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
if (!(_r)) ABORT("Out of memory: can't allocate %u bytes", (_s)); \
|
if (!(_r)) ABORT("Out of memory: can't allocate %u bytes", (_s)); \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Allocator increments for ck_realloc_block(). */
|
/* Allocator increments for ck_realloc_block(). */
|
||||||
@ -235,14 +234,13 @@ static inline u8 *DFL_ck_memdup_str(u8 *mem, u32 size) {
|
|||||||
|
|
||||||
# define alloc_printf(_str...) \
|
# define alloc_printf(_str...) \
|
||||||
({ \
|
({ \
|
||||||
\
|
|
||||||
u8 *_tmp; \
|
u8 *_tmp; \
|
||||||
s32 _len = snprintf(NULL, 0, _str); \
|
s32 _len = snprintf(NULL, 0, _str); \
|
||||||
if (_len < 0) FATAL("Whoa, snprintf() fails?!"); \
|
if (_len < 0) FATAL("Whoa, snprintf() fails?!"); \
|
||||||
_tmp = ck_alloc(_len + 1); \
|
_tmp = ck_alloc(_len + 1); \
|
||||||
snprintf((char *)_tmp, _len + 1, _str); \
|
snprintf((char *)_tmp, _len + 1, _str); \
|
||||||
_tmp; \
|
_tmp; \
|
||||||
\
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Macro to enforce allocation limits as a last-resort defense against
|
/* Macro to enforce allocation limits as a last-resort defense against
|
||||||
@ -250,18 +248,18 @@ static inline u8 *DFL_ck_memdup_str(u8 *mem, u32 size) {
|
|||||||
|
|
||||||
# define ALLOC_CHECK_SIZE(_s) \
|
# define ALLOC_CHECK_SIZE(_s) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
if ((_s) > MAX_ALLOC) ABORT("Bad alloc request: %u bytes", (_s)); \
|
if ((_s) > MAX_ALLOC) ABORT("Bad alloc request: %u bytes", (_s)); \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Macro to check malloc() failures and the like. */
|
/* Macro to check malloc() failures and the like. */
|
||||||
|
|
||||||
# define ALLOC_CHECK_RESULT(_r, _s) \
|
# define ALLOC_CHECK_RESULT(_r, _s) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
if (!(_r)) ABORT("Out of memory: can't allocate %u bytes", (_s)); \
|
if (!(_r)) ABORT("Out of memory: can't allocate %u bytes", (_s)); \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Magic tokens used to mark used / freed chunks. */
|
/* Magic tokens used to mark used / freed chunks. */
|
||||||
@ -287,31 +285,30 @@ static inline u8 *DFL_ck_memdup_str(u8 *mem, u32 size) {
|
|||||||
|
|
||||||
# define CHECK_PTR(_p) \
|
# define CHECK_PTR(_p) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
if (_p) { \
|
if (_p) { \
|
||||||
\
|
|
||||||
if (ALLOC_C1(_p) ^ ALLOC_MAGIC_C1) { \
|
if (ALLOC_C1(_p) ^ ALLOC_MAGIC_C1) { \
|
||||||
\
|
|
||||||
if (ALLOC_C1(_p) == ALLOC_MAGIC_F) \
|
if (ALLOC_C1(_p) == ALLOC_MAGIC_F) \
|
||||||
ABORT("Use after free."); \
|
ABORT("Use after free."); \
|
||||||
else \
|
else \
|
||||||
ABORT("Corrupted head alloc canary."); \
|
ABORT("Corrupted head alloc canary."); \
|
||||||
\
|
|
||||||
} \
|
} \
|
||||||
|
|
||||||
if (ALLOC_C2(_p) ^ ALLOC_MAGIC_C2) \
|
if (ALLOC_C2(_p) ^ ALLOC_MAGIC_C2) \
|
||||||
ABORT("Corrupted tail alloc canary."); \
|
ABORT("Corrupted tail alloc canary."); \
|
||||||
\
|
|
||||||
} \
|
} \
|
||||||
|
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define CHECK_PTR_EXPR(_p) \
|
# define CHECK_PTR_EXPR(_p) \
|
||||||
({ \
|
({ \
|
||||||
\
|
|
||||||
typeof(_p) _tmp = (_p); \
|
typeof(_p) _tmp = (_p); \
|
||||||
CHECK_PTR(_tmp); \
|
CHECK_PTR(_tmp); \
|
||||||
_tmp; \
|
_tmp; \
|
||||||
\
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Allocate a buffer, explicitly not zeroing it. Returns NULL for zero-sized
|
/* Allocate a buffer, explicitly not zeroing it. Returns NULL for zero-sized
|
||||||
@ -745,7 +742,8 @@ static inline void TRK_ck_free(void *ptr, const char *file, const char *func,
|
|||||||
|
|
||||||
# define ck_alloc(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
|
# define ck_alloc(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
|
||||||
#define ck_alloc_nozero(_p1) TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
|
# define ck_alloc_nozero(_p1) \
|
||||||
|
TRK_ck_alloc(_p1, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
|
||||||
# define ck_realloc(_p1, _p2) \
|
# define ck_realloc(_p1, _p2) \
|
||||||
TRK_ck_realloc(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
|
TRK_ck_realloc(_p1, _p2, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
@ -83,20 +83,20 @@ typedef int64_t s64;
|
|||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
# define MIN(a, b) \
|
# define MIN(a, b) \
|
||||||
({ \
|
({ \
|
||||||
\
|
|
||||||
__typeof__(a) _a = (a); \
|
__typeof__(a) _a = (a); \
|
||||||
__typeof__(b) _b = (b); \
|
__typeof__(b) _b = (b); \
|
||||||
_a < _b ? _a : _b; \
|
_a < _b ? _a : _b;
|
||||||
\
|
|
||||||
})
|
})
|
||||||
|
|
||||||
# define MAX(a, b) \
|
# define MAX(a, b) \
|
||||||
({ \
|
({ \
|
||||||
\
|
|
||||||
__typeof__(a) _a = (a); \
|
__typeof__(a) _a = (a); \
|
||||||
__typeof__(b) _b = (b); \
|
__typeof__(b) _b = (b); \
|
||||||
_a > _b ? _a : _b; \
|
_a > _b ? _a : _b;
|
||||||
\
|
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif /* !MIN */
|
#endif /* !MIN */
|
||||||
|
|
||||||
#define SWAP16(_x) \
|
#define SWAP16(_x) \
|
||||||
|
@ -43,23 +43,23 @@
|
|||||||
# ifdef __NR_getrandom
|
# ifdef __NR_getrandom
|
||||||
# define arc4random_buf(p, l) \
|
# define arc4random_buf(p, l) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
ssize_t rd = syscall(__NR_getrandom, p, l, 0); \
|
ssize_t rd = syscall(__NR_getrandom, p, l, 0); \
|
||||||
if (rd != l) DEBUGF("getrandom failed"); \
|
if (rd != l) DEBUGF("getrandom failed"); \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
# define arc4random_buf(p, l) \
|
# define arc4random_buf(p, l) \
|
||||||
do { \
|
do { \
|
||||||
\
|
|
||||||
srand(time(NULL)); \
|
srand(time(NULL)); \
|
||||||
u32 i; \
|
u32 i; \
|
||||||
u8 *ptr = (u8 *)p; \
|
u8 *ptr = (u8 *)p; \
|
||||||
for (i = 0; i < l; i++) \
|
for (i = 0; i < l; i++) \
|
||||||
ptr[i] = rand() % INT_MAX; \
|
ptr[i] = rand() % INT_MAX; \
|
||||||
\
|
\
|
||||||
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
@ -137,13 +137,13 @@ struct InsTrim : public ModulePass {
|
|||||||
getenv("AFL_LLVM_SKIPSINGLEBLOCK"))
|
getenv("AFL_LLVM_SKIPSINGLEBLOCK"))
|
||||||
function_minimum_size = 2;
|
function_minimum_size = 2;
|
||||||
|
|
||||||
unsigned PrevLocSize = 0;
|
unsigned int PrevLocSize = 0;
|
||||||
char * ngram_size_str = getenv("AFL_LLVM_NGRAM_SIZE");
|
char * ngram_size_str = getenv("AFL_LLVM_NGRAM_SIZE");
|
||||||
if (!ngram_size_str) ngram_size_str = getenv("AFL_NGRAM_SIZE");
|
if (!ngram_size_str) ngram_size_str = getenv("AFL_NGRAM_SIZE");
|
||||||
char *ctx_str = getenv("AFL_LLVM_CTX");
|
char *ctx_str = getenv("AFL_LLVM_CTX");
|
||||||
|
|
||||||
#ifdef AFL_HAVE_VECTOR_INTRINSICS
|
#ifdef AFL_HAVE_VECTOR_INTRINSICS
|
||||||
int ngram_size = 0;
|
unsigned int ngram_size = 0;
|
||||||
/* Decide previous location vector size (must be a power of two) */
|
/* Decide previous location vector size (must be a power of two) */
|
||||||
VectorType *PrevLocTy;
|
VectorType *PrevLocTy;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user