Sigrid Solveig Haflínudóttiradd a harness target, leave readtags example alone013e8392 years agoHistory
104 lines · 1.8 KB · C
RawDownload
#include <assert.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include "tags.h" typedef struct Aux Aux; struct Aux {	const uint8_t *in;	int sz;	int off;}; #define USED(x) (void)x #ifndef __AFL_FUZZ_TESTCASE_LEN  ssize_t fuzz_len;  #define __AFL_FUZZ_TESTCASE_LEN fuzz_len  unsigned char fuzz_buf[1024000];  #define __AFL_FUZZ_TESTCASE_BUF fuzz_buf  #define __AFL_FUZZ_INIT() void sync(void);  #define __AFL_LOOP(x) ((fuzz_len = read(0, fuzz_buf, sizeof(fuzz_buf))) > 0 ? 1 : 0)  #define __AFL_INIT() sync()#endif __AFL_FUZZ_INIT() static voidtag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagread f){	USED(ctx); USED(t);  USED(k); USED(v); USED(offset); USED(size); USED(f);} static voidtoc(Tagctx *ctx, int ms, int offset){	USED(ctx); USED(ms); USED(offset);} static intctxread(Tagctx *ctx, void *buf, int cnt){	Aux *aux = ctx->aux;	int max = aux->sz - aux->off;	if(cnt < 0)		cnt = 0;	else if(cnt > max)		cnt = max;	memcpy(buf, aux->in, cnt);	aux->off += cnt;	return cnt;} static intctxseek(Tagctx *ctx, int offset, int whence){	Aux *aux = ctx->aux;	if(whence == 0)		aux->off = offset;	else if(whence == 1)		aux->off += offset;	else if(whence == 2)		aux->off = aux->sz + offset;	if(aux->off < 0)		aux->off = 0;	else if(aux->off > aux->sz)		aux->off = aux->sz;	return aux->off;} intmain(int argc, char **argv){	char buf[256];	Aux aux;	Tagctx ctx = {		.read = ctxread,		.seek = ctxseek,		.tag = tag,		.toc = toc,		.buf = buf,		.bufsz = sizeof(buf),		.aux = &aux,	}; 	USED(argc); USED(argv); 	#ifdef __AFL_HAVE_MANUAL_CONTROL	__AFL_INIT();	#endif 	aux.in = __AFL_FUZZ_TESTCASE_BUF;	while(__AFL_LOOP(10000)){		aux.sz = __AFL_FUZZ_TESTCASE_LEN;		if(aux.sz < 8)			continue;		aux.off = 0;		tagsget(&ctx);	} 	return 0;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t