Skip to content

Commit

Permalink
2.46b
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-huet committed Jul 29, 2017
1 parent 2cf1924 commit 1842561
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/* Version string: */

#define VERSION "2.45b"
#define VERSION "2.46b"

/******************************************************
* *
Expand Down
52 changes: 52 additions & 0 deletions dictionaries/json.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# AFL dictionary for JSON
# -----------------------
#
# Just the very basics.
#
# Inspired by a dictionary by Jakub Wilk <[email protected]>
#

"0"
",0"
":0"
"0:"
"-1.2e+3"

"true"
"false"
"null"

"\"\""
",\"\""
":\"\""
"\"\":"

"{}"
",{}"
":{}"
"{\"\":0}"
"{{}}"

"[]"
",[]"
":[]"
"[0]"
"[[]]"

"''"
"\\"
"\\b"
"\\f"
"\\n"
"\\r"
"\\t"
"\\u0000"
"\\x00"
"\\0"
"\\uD800\\uDC00"
"\\uDBFF\\uDFFF"

"\"\":0"
"//"
"/**/"
9 changes: 9 additions & 0 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Not sure if you should upgrade? The lowest currently recommended version
is 2.41b. If you're stuck on an earlier release, it's strongly advisable
to get on with the times.

--------------
Version 2.46b:
--------------

- libdislocator now supports AFL_LD_NO_CALLOC_OVER for folks who do not
want to abort on calloc() overflows.

- Made a minor fix to libtokencap. Reported by Daniel Stender.

--------------
Version 2.45b:
--------------
Expand Down
4 changes: 4 additions & 0 deletions docs/env_variables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ The library honors three environmental variables:
- AFL_LD_VERBOSE causes the library to output some diagnostic messages
that may be useful for pinpointing the cause of any observed issues.

- AFL_LD_NO_CALLOC_OVER inhibits abort() on calloc() overflows. Most
of the common allocators check for that internally and return NULL, so
it's a security risk only in more exotic setups.

8) Settings for libtokencap.so
------------------------------

Expand Down
14 changes: 12 additions & 2 deletions libdislocator/libdislocator.so.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@

static u32 max_mem = MAX_ALLOC; /* Max heap usage to permit */
static u8 alloc_verbose, /* Additional debug messages */
hard_fail; /* abort() when max_mem exceeded? */
hard_fail, /* abort() when max_mem exceeded? */
no_calloc_over; /* abort() on calloc() overflows? */

static __thread size_t total_mem; /* Currently allocated mem */

Expand Down Expand Up @@ -153,9 +154,17 @@ void* calloc(size_t elem_len, size_t elem_cnt) {

/* Perform some sanity checks to detect obvious issues... */

if (elem_cnt && len / elem_cnt != elem_len)
if (elem_cnt && len / elem_cnt != elem_len) {

if (no_calloc_over) {
DEBUGF("calloc(%zu, %zu) would overflow, returning NULL", elem_len, elem_cnt);
return NULL;
}

FATAL("calloc(%zu, %zu) would overflow", elem_len, elem_cnt);

}

ret = __dislocator_alloc(len);

DEBUGF("calloc(%zu, %zu) = %p [%zu total]", elem_len, elem_cnt, ret,
Expand Down Expand Up @@ -254,5 +263,6 @@ __attribute__((constructor)) void __dislocator_init(void) {

alloc_verbose = !!getenv("AFL_LD_VERBOSE");
hard_fail = !!getenv("AFL_LD_HARD_FAIL");
no_calloc_over = !!getenv("AFL_LD_NO_CALLOC_OVER");

}
8 changes: 4 additions & 4 deletions libtokencap/libtokencap.so.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int memcmp(const void* mem1, const void* mem2, size_t len) {

#undef strstr

const char* strstr(const char* haystack, const char* needle) {
char* strstr(const char* haystack, const char* needle) {

if (__tokencap_is_ro(haystack))
__tokencap_dump(haystack, strlen(haystack), 1);
Expand All @@ -257,7 +257,7 @@ const char* strstr(const char* haystack, const char* needle) {

while(*n && *h && *n == *h) n++, h++;

if(!*n) return haystack;
if(!*n) return (char*)haystack;

} while (*(haystack++));

Expand All @@ -268,7 +268,7 @@ const char* strstr(const char* haystack, const char* needle) {

#undef strcasestr

const char* strcasestr(const char* haystack, const char* needle) {
char* strcasestr(const char* haystack, const char* needle) {

if (__tokencap_is_ro(haystack))
__tokencap_dump(haystack, strlen(haystack), 1);
Expand All @@ -283,7 +283,7 @@ const char* strcasestr(const char* haystack, const char* needle) {

while(*n && *h && tolower(*n) == tolower(*h)) n++, h++;

if(!*n) return haystack;
if(!*n) return (char*)haystack;

} while(*(haystack++));

Expand Down

0 comments on commit 1842561

Please sign in to comment.