warn on _AFL and __AFL env vars

This commit is contained in:
van Hauser
2020-12-23 17:56:39 +01:00
parent 1c79687dfe
commit 03849d147a
7 changed files with 44 additions and 29 deletions

View File

@ -363,7 +363,8 @@ static inline void *DFL_ck_realloc(void *orig, u32 size) {
if (orig) { if (orig) {
memcpy((char *)ret + ALLOC_OFF_HEAD, (char *)orig + ALLOC_OFF_HEAD, MIN(size, old_size)); memcpy((char *)ret + ALLOC_OFF_HEAD, (char *)orig + ALLOC_OFF_HEAD,
MIN(size, old_size));
memset((char *)orig + ALLOC_OFF_HEAD, 0xFF, old_size); memset((char *)orig + ALLOC_OFF_HEAD, 0xFF, old_size);
ALLOC_C1((char *)orig + ALLOC_OFF_HEAD) = ALLOC_MAGIC_F; ALLOC_C1((char *)orig + ALLOC_OFF_HEAD) = ALLOC_MAGIC_F;

View File

@ -103,11 +103,11 @@ static u32 map_size = MAP_SIZE;
/* Classify tuple counts. This is a slow & naive version, but good enough here. /* Classify tuple counts. This is a slow & naive version, but good enough here.
*/ */
#define TIMES4(x) x,x,x,x #define TIMES4(x) x, x, x, x
#define TIMES8(x) TIMES4(x),TIMES4(x) #define TIMES8(x) TIMES4(x), TIMES4(x)
#define TIMES16(x) TIMES8(x),TIMES8(x) #define TIMES16(x) TIMES8(x), TIMES8(x)
#define TIMES32(x) TIMES16(x),TIMES16(x) #define TIMES32(x) TIMES16(x), TIMES16(x)
#define TIMES64(x) TIMES32(x),TIMES32(x) #define TIMES64(x) TIMES32(x), TIMES32(x)
static u8 count_class_lookup[256] = { static u8 count_class_lookup[256] = {
[0] = 0, [0] = 0,
@ -121,6 +121,7 @@ static u8 count_class_lookup[256] = {
[128] = TIMES64(128) [128] = TIMES64(128)
}; };
#undef TIMES64 #undef TIMES64
#undef TIMES32 #undef TIMES32
#undef TIMES16 #undef TIMES16

View File

@ -432,7 +432,9 @@ void check_environment_vars(char **envp) {
char *env, *val; char *env, *val;
while ((env = envp[index++]) != NULL) { while ((env = envp[index++]) != NULL) {
if (strncmp(env, "ALF_", 4) == 0) { if (strncmp(env, "ALF_", 4) == 0 || strncmp(env, "_ALF", 4) == 0 ||
strncmp(env, "__ALF", 5) == 0 || strncmp(env, "_AFL", 4) == 0 ||
strncmp(env, "__AFL", 5) == 0) {
WARNF("Potentially mistyped AFL environment variable: %s", env); WARNF("Potentially mistyped AFL environment variable: %s", env);
issue_detected = 1; issue_detected = 1;

View File

@ -26,7 +26,7 @@
#include "afl-fuzz.h" #include "afl-fuzz.h"
#include <limits.h> #include <limits.h>
#if !defined NAME_MAX #if !defined NAME_MAX
#define NAME_MAX _XOPEN_NAME_MAX #define NAME_MAX _XOPEN_NAME_MAX
#endif #endif
/* Write bitmap to file. The bitmap is useful mostly for the secret /* Write bitmap to file. The bitmap is useful mostly for the secret
@ -143,12 +143,14 @@ u32 count_non_255_bytes(afl_state_t *afl, u8 *mem) {
and replacing it with 0x80 or 0x01 depending on whether the tuple and replacing it with 0x80 or 0x01 depending on whether the tuple
is hit or not. Called on every new crash or timeout, should be is hit or not. Called on every new crash or timeout, should be
reasonably fast. */ reasonably fast. */
#define TIMES4(x) x,x,x,x #define TIMES4(x) x, x, x, x
#define TIMES8(x) TIMES4(x),TIMES4(x) #define TIMES8(x) TIMES4(x), TIMES4(x)
#define TIMES16(x) TIMES8(x),TIMES8(x) #define TIMES16(x) TIMES8(x), TIMES8(x)
#define TIMES32(x) TIMES16(x),TIMES16(x) #define TIMES32(x) TIMES16(x), TIMES16(x)
#define TIMES64(x) TIMES32(x),TIMES32(x) #define TIMES64(x) TIMES32(x), TIMES32(x)
#define TIMES255(x) TIMES64(x),TIMES64(x),TIMES64(x),TIMES32(x),TIMES16(x),TIMES8(x),TIMES4(x),x,x,x #define TIMES255(x) \
TIMES64(x), TIMES64(x), TIMES64(x), TIMES32(x), TIMES16(x), TIMES8(x), \
TIMES4(x), x, x, x
const u8 simplify_lookup[256] = { const u8 simplify_lookup[256] = {
[0] = 1, [1] = TIMES255(128) [0] = 1, [1] = TIMES255(128)
@ -172,6 +174,7 @@ const u8 count_class_lookup8[256] = {
[128] = TIMES64(128) [128] = TIMES64(128)
}; };
#undef TIMES255 #undef TIMES255
#undef TIMES64 #undef TIMES64
#undef TIMES32 #undef TIMES32

View File

@ -29,7 +29,7 @@
#include <signal.h> #include <signal.h>
#include <limits.h> #include <limits.h>
#if !defined NAME_MAX #if !defined NAME_MAX
#define NAME_MAX _XOPEN_NAME_MAX #define NAME_MAX _XOPEN_NAME_MAX
#endif #endif
#include "cmplog.h" #include "cmplog.h"

View File

@ -98,17 +98,23 @@ static sharedmem_t * shm_fuzz;
/* Classify tuple counts. Instead of mapping to individual bits, as in /* Classify tuple counts. Instead of mapping to individual bits, as in
afl-fuzz.c, we map to more user-friendly numbers between 1 and 8. */ afl-fuzz.c, we map to more user-friendly numbers between 1 and 8. */
#define TIMES4(x) x,x,x,x #define TIMES4(x) x, x, x, x
#define TIMES8(x) TIMES4(x),TIMES4(x) #define TIMES8(x) TIMES4(x), TIMES4(x)
#define TIMES16(x) TIMES8(x),TIMES8(x) #define TIMES16(x) TIMES8(x), TIMES8(x)
#define TIMES32(x) TIMES16(x),TIMES16(x) #define TIMES32(x) TIMES16(x), TIMES16(x)
#define TIMES64(x) TIMES32(x),TIMES32(x) #define TIMES64(x) TIMES32(x), TIMES32(x)
#define TIMES96(x) TIMES64(x),TIMES32(x) #define TIMES96(x) TIMES64(x), TIMES32(x)
#define TIMES128(x) TIMES64(x),TIMES64(x) #define TIMES128(x) TIMES64(x), TIMES64(x)
static const u8 count_class_human[256] = { static const u8 count_class_human[256] = {
[0] = 0, [1] = 1, [2] = 2, [3] = 3, [0] = 0,
[4] = TIMES4(4), [8] = TIMES8(5),[16] = TIMES16(6),[32] = TIMES96(7), [1] = 1,
[2] = 2,
[3] = 3,
[4] = TIMES4(4),
[8] = TIMES8(5),
[16] = TIMES16(6),
[32] = TIMES96(7),
[128] = TIMES128(8) [128] = TIMES128(8)
}; };
@ -126,6 +132,7 @@ static const u8 count_class_binary[256] = {
[128] = TIMES64(128) [128] = TIMES64(128)
}; };
#undef TIMES128 #undef TIMES128
#undef TIMES96 #undef TIMES96
#undef TIMES64 #undef TIMES64

View File

@ -98,11 +98,11 @@ static sharedmem_t * shm_fuzz;
/* Classify tuple counts. This is a slow & naive version, but good enough here. /* Classify tuple counts. This is a slow & naive version, but good enough here.
*/ */
#define TIMES4(x) x,x,x,x #define TIMES4(x) x, x, x, x
#define TIMES8(x) TIMES4(x),TIMES4(x) #define TIMES8(x) TIMES4(x), TIMES4(x)
#define TIMES16(x) TIMES8(x),TIMES8(x) #define TIMES16(x) TIMES8(x), TIMES8(x)
#define TIMES32(x) TIMES16(x),TIMES16(x) #define TIMES32(x) TIMES16(x), TIMES16(x)
#define TIMES64(x) TIMES32(x),TIMES32(x) #define TIMES64(x) TIMES32(x), TIMES32(x)
static const u8 count_class_lookup[256] = { static const u8 count_class_lookup[256] = {
[0] = 0, [0] = 0,
@ -116,6 +116,7 @@ static const u8 count_class_lookup[256] = {
[128] = TIMES64(128) [128] = TIMES64(128)
}; };
#undef TIMES64 #undef TIMES64
#undef TIMES32 #undef TIMES32
#undef TIMES16 #undef TIMES16