Skip to content

Commit

Permalink
1.77b
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-huet committed May 6, 2015
1 parent ccb23c5 commit 8b8817f
Show file tree
Hide file tree
Showing 156 changed files with 317 additions and 158 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#

PROGNAME = afl
VERSION = 1.76b
VERSION = 1.77b

PREFIX ?= /usr/local
BIN_PATH = $(PREFIX)/bin
Expand Down
4 changes: 2 additions & 2 deletions afl-as.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void edit_params(int argc, char** argv) {

static void add_instrumentation(void) {

static u8 line[MAX_AS_LINE];
static u8 line[MAX_LINE];

FILE* inf;
FILE* outf;
Expand Down Expand Up @@ -242,7 +242,7 @@ static void add_instrumentation(void) {

if (!outf) PFATAL("fdopen() failed");

while (fgets(line, MAX_AS_LINE, inf)) {
while (fgets(line, MAX_LINE, inf)) {

/* In some cases, we want to defer writing the instrumentation trampoline
until after all the labels, macros, comments, etc. If we're in this
Expand Down
143 changes: 142 additions & 1 deletion afl-fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,133 @@ static int compare_extras_use_d(const void* p1, const void* p2) {
}


/* Read extras from a file, sort by size. */

static void load_extras_file(u8* fname) {

FILE* f;
u32 min_len = MAX_DICT_FILE, max_len = 0;
u8 buf[MAX_LINE];
u8 *lptr;
u32 cur_line = 0;

f = fopen(fname, "r");

if (!f) PFATAL("Unable to open '%s'", fname);

while ((lptr = fgets(buf, MAX_LINE, f))) {

u8 *rptr, *wptr;
u32 klen = 0;

cur_line++;

/* Trim on left and right. */

while (isspace(*lptr)) lptr++;

rptr = lptr + strlen(lptr) - 1;
while (rptr >= lptr && isspace(*rptr)) rptr--;
rptr++;
*rptr = 0;

/* Skip empty lines and comments. */

if (!*lptr || *lptr == '#') continue;

/* All other lines must end with '"', which we can consume. */

rptr--;

if (rptr < lptr || *rptr != '"')
FATAL("Malformed name=\"value\" pair in line %u.", cur_line);

*rptr = 0;

/* Skip alphanumerics and dashes (label). */

while (isalnum(*lptr) || *lptr == '_') lptr++;

/* Skip whitespace and = signs. */

while (isspace(*lptr) || *lptr == '=') lptr++;

/* Consume opening '"'. */

if (*lptr != '"')
FATAL("Malformed name=\"keyword\" pair in line %u.", cur_line);

lptr++;

if (!*lptr) FATAL("Empty keyword in line %u.", cur_line);

/* Okay, let's allocate memory and copy data between "...", handling
\xNN escaping, \\, and \". */

extras = ck_realloc_block(extras, (extras_cnt + 1) *
sizeof(struct extra_data));

wptr = extras[extras_cnt].data = ck_alloc(rptr - lptr);

while (*lptr) {

char* hexdigits = "0123456789abcdef";

switch (*lptr) {

case 1 ... 31:
case 128 ... 255:
FATAL("Non-printable characters in line %u.", cur_line);

case '\\':

lptr++;

if (*lptr == '\\' || *lptr == '"') {
*(wptr++) = *(lptr++);
klen++;
break;
}

if (*lptr != 'x' || !isxdigit(lptr[1]) || !isxdigit(lptr[2]))
FATAL("Invalid escaping (not \\xNN) in line %u.", cur_line);

*(wptr++) =
((strchr(hexdigits, tolower(lptr[1])) - hexdigits) << 4) |
(strchr(hexdigits, tolower(lptr[2])) - hexdigits);

lptr += 3;
klen++;

break;

default:

*(wptr++) = *(lptr++);
klen++;

}

}

extras[extras_cnt].len = klen;

if (extras[extras_cnt].len > MAX_DICT_FILE)
FATAL("Keyword too big in line %u (%s, limit is %s)", cur_line,
DMS(klen), DMS(MAX_DICT_FILE));

if (min_len > klen) min_len = klen;
if (max_len < klen) max_len = klen;

extras_cnt++;

}

fclose(f);

}


/* Read extras from the extras directory and sort them by size. */

static void load_extras(u8* dir) {
Expand All @@ -1365,7 +1492,16 @@ static void load_extras(u8* dir) {

d = opendir(dir);

if (!d) PFATAL("Unable to open '%s'", dir);
if (!d) {

if (errno == ENOTDIR) {
load_extras_file(dir);
goto check_and_sort;
}

PFATAL("Unable to open '%s'", dir);

}

while ((de = readdir(d))) {

Expand Down Expand Up @@ -1411,6 +1547,9 @@ static void load_extras(u8* dir) {
}

closedir(d);

check_and_sort:

if (!extras_cnt) FATAL("No usable files in '%s'", dir);

qsort(extras, extras_cnt, sizeof(struct extra_data), compare_extras_len);
Expand All @@ -1429,6 +1568,8 @@ static void load_extras(u8* dir) {
}




/* Helper function for maybe_add_auto() */

static inline u8 memcmp_nocase(u8* m1, u8* m2, u32 len) {
Expand Down
5 changes: 3 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@

#define RESEED_RNG 10000

/* Maximum line length passed from GCC to 'as': */
/* Maximum line length passed from GCC to 'as' and used for parsing
configuration files: */

#define MAX_AS_LINE 8192
#define MAX_LINE 8192

/* Environment variable used to pass SHM ID to the called program. */

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

--------------
Version 1.77b:
--------------

- Extended the -x option to support single-file dictionaries.

- Removed newlines from HTML keywords in testcases/_extras/html/.

--------------
Version 1.76b:
--------------

- Very significantly reduced the number of duplicate execs during
deterministic checks, chiefly in int16 and int32 stages.
deterministic checks, chiefly in int16 and int32 stages. Confirmed
identical path yields. This should improve early-stage efficiency by
around 5-10%.

- Reduced the likelihood of duplicate non-deterministic execs by
bumping up lowest stacking factor from 1 to 2.
bumping up lowest stacking factor from 1 to 2. Quickly confirmed
that this doesn't seem to have significant impact on coverage with
libpng.

- Added a note about integrating afl-fuzz with third-party tools.

Expand Down
5 changes: 5 additions & 0 deletions docs/README
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ existing syntax tokens in the input corpus by watching the instrumentation
very closely during deterministic byte flips. This works for some types of
parsers and grammars, but isn't nearly as good as the -x mode.

PPS. Due to popular demand, it is now also possible to specify a file dictionary
via -x. The file must follow the name="value" format, one token per line.
Alphanumeric names are ignored, along with empty lines of lines that start with #.
Non-printable and control characters must be escaped within values using \xNN.

10) Crash triage
----------------

Expand Down
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<a>
<a>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_abbr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<abbr>
<abbr>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_acronym
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<acronym>
<acronym>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_address
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<address>
<address>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_annotation-xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<annotation-xml>
<annotation-xml>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_applet
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<applet>
<applet>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_area
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<area>
<area>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_article
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<article>
<article>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_aside
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<aside>
<aside>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_audio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<audio>
<audio>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<b>
<b>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_base
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<base>
<base>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_basefont
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<basefont>
<basefont>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_bdi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<bdi>
<bdi>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_bdo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<bdo>
<bdo>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_bgsound
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<bgsound>
<bgsound>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_big
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<big>
<big>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_blink
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<blink>
<blink>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_blockquote
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<blockquote>
<blockquote>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_body
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<body>
<body>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_br
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<br>
<br>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_button
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button>
<button>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_canvas
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<canvas>
<canvas>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_caption
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<caption>
<caption>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_center
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<center>
<center>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_cite
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<cite>
<cite>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_code
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<code>
<code>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_col
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<col>
<col>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_colgroup
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<colgroup>
<colgroup>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_data
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<data>
<data>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_datalist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<datalist>
<datalist>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_dd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<dd>
<dd>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_del
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<del>
<del>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_desc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<desc>
<desc>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_details
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<details>
<details>
2 changes: 1 addition & 1 deletion testcases/_extras/html/basic_tags/tag_dfn
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<dfn>
<dfn>
Loading

0 comments on commit 8b8817f

Please sign in to comment.