fixed indentation for afl runner

This commit is contained in:
Peter Andersson
2017-07-14 20:26:26 +02:00
parent ba8d08791b
commit e92a6c32fc
+122 -122
View File
@@ -635,7 +635,7 @@ static int run_fuzz_test(FILE *f, int maxfds, int debuglog) {
// The list of 8 modes that are chosen. SPIFFS_EXCL is not present -- it probably ought to be. // The list of 8 modes that are chosen. SPIFFS_EXCL is not present -- it probably ought to be.
int modes[8] = {SPIFFS_RDONLY, SPIFFS_RDWR, SPIFFS_RDWR|SPIFFS_TRUNC, SPIFFS_RDWR|SPIFFS_CREAT, SPIFFS_RDWR|SPIFFS_CREAT|SPIFFS_TRUNC, int modes[8] = {SPIFFS_RDONLY, SPIFFS_RDWR, SPIFFS_RDWR|SPIFFS_TRUNC, SPIFFS_RDWR|SPIFFS_CREAT, SPIFFS_RDWR|SPIFFS_CREAT|SPIFFS_TRUNC,
SPIFFS_WRONLY|SPIFFS_CREAT|SPIFFS_TRUNC, SPIFFS_RDWR|SPIFFS_CREAT|SPIFFS_TRUNC|SPIFFS_DIRECT, SPIFFS_WRONLY}; SPIFFS_WRONLY|SPIFFS_CREAT|SPIFFS_TRUNC, SPIFFS_RDWR|SPIFFS_CREAT|SPIFFS_TRUNC|SPIFFS_DIRECT, SPIFFS_WRONLY};
char buff[2048]; char buff[2048];
for (i = 0; i < sizeof(buff); i++) { for (i = 0; i < sizeof(buff); i++) {
@@ -657,13 +657,13 @@ static int run_fuzz_test(FILE *f, int maxfds, int debuglog) {
int fdn = ((arg >> 6) & 3) % maxfds; int fdn = ((arg >> 6) & 3) % maxfds;
int rc; int rc;
switch(c) { switch(c) {
case 'O': case 'O':
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
LOGOP(" close(%d)\n", fd[fdn]); LOGOP(" close(%d)\n", fd[fdn]);
SPIFFS_close(FS, fd[fdn]); SPIFFS_close(FS, fd[fdn]);
openindex[fdn] = -1; openindex[fdn] = -1;
fd[fdn] = -1; fd[fdn] = -1;
} }
#ifndef HAVE_MULTIPLE_OPEN #ifndef HAVE_MULTIPLE_OPEN
{ {
int index = (arg >> 3) & 7; int index = (arg >> 3) & 7;
@@ -677,149 +677,149 @@ static int run_fuzz_test(FILE *f, int maxfds, int debuglog) {
} }
} }
#endif #endif
LOGOP(" open(\"%s\", 0x%x)", filename[(arg>>3) & 7], modes[arg & 7]); LOGOP(" open(\"%s\", 0x%x)", filename[(arg>>3) & 7], modes[arg & 7]);
fd[fdn] = SPIFFS_open(FS, filename[(arg>>3) & 7], modes[arg & 7], 0); fd[fdn] = SPIFFS_open(FS, filename[(arg>>3) & 7], modes[arg & 7], 0);
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
openindex[fdn] = (arg >> 3) & 7; openindex[fdn] = (arg >> 3) & 7;
}
LOGOP(" -> %d\n", fd[fdn]);
break;
case 'S':
if (fd[fdn] >= 0) {
int offset = (14 << (arg & 7)) + arg;
if (arg & 16) {
offset = -offset;
} }
LOGOP(" -> %d\n", fd[fdn]); int whence = (arg & 63) % 3;
break; LOGOP(" lseek(%d, %d, %d)\n", fd[fdn], offset, whence);
SPIFFS_lseek(FS, fd[fdn], offset, whence);
}
break;
case 'S': case 'R':
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
int offset = (14 << (arg & 7)) + arg; LOGOP(" read(%d, , %d)", fd[fdn], (15 << (arg & 7)) + (arg & 127));
if (arg & 16) { int rlen = SPIFFS_read(FS, fd[fdn], rbuff, (15 << (arg & 7)) + (arg & 127));
offset = -offset; LOGOP(" -> %d\n", rlen);
} }
int whence = (arg & 63) % 3; break;
LOGOP(" lseek(%d, %d, %d)\n", fd[fdn], offset, whence);
SPIFFS_lseek(FS, fd[fdn], offset, whence);
}
break;
case 'R': case 'W':
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
LOGOP(" read(%d, , %d)", fd[fdn], (15 << (arg & 7)) + (arg & 127)); LOGOP(" write(%d, , %d)", fd[fdn], (15 << (arg & 7)) + (arg & 127));
int rlen = SPIFFS_read(FS, fd[fdn], rbuff, (15 << (arg & 7)) + (arg & 127)); rc = SPIFFS_write(FS, fd[fdn], buff, (15 << (arg & 7)) + (arg & 127));
LOGOP(" -> %d\n", rlen); LOGOP(" -> %d\n", rc);
} }
break; break;
case 'W': case 'C':
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
LOGOP(" write(%d, , %d)", fd[fdn], (15 << (arg & 7)) + (arg & 127)); LOGOP(" close(%d)\n", fd[fdn]);
rc = SPIFFS_write(FS, fd[fdn], buff, (15 << (arg & 7)) + (arg & 127)); SPIFFS_close(FS, fd[fdn]);
LOGOP(" -> %d\n", rc); }
} fd[fdn] = -1;
break; openindex[fdn] = -1;
break;
case 'C': case 'b':
if (fd[fdn] >= 0) { add = fgetc(f);
LOGOP(" close(%d)\n", fd[fdn]); for (i = 0; i < sizeof(buff); i++) {
SPIFFS_close(FS, fd[fdn]); buff[i] = add + i * arg;
} }
fd[fdn] = -1; break;
openindex[fdn] = -1;
break;
case 'b': case 'f':
add = fgetc(f); if (fd[fdn] >= 0) {
for (i = 0; i < sizeof(buff); i++) { LOGOP(" fflush(%d)\n", fd[fdn]);
buff[i] = add + i * arg; SPIFFS_fflush(FS, fd[fdn]);
} }
break; break;
case 'f':
if (fd[fdn] >= 0) {
LOGOP(" fflush(%d)\n", fd[fdn]);
SPIFFS_fflush(FS, fd[fdn]);
}
break;
#ifdef HAVE_REMOVE_OPEN #ifdef HAVE_REMOVE_OPEN
case 'D': case 'D':
if (fd[fdn] >= 0) { if (fd[fdn] >= 0) {
LOGOP(" fremove(%d)\n", fd[fdn]); LOGOP(" fremove(%d)\n", fd[fdn]);
SPIFFS_fremove(FS, fd[fdn]); SPIFFS_fremove(FS, fd[fdn]);
} }
break; break;
#endif #endif
case 'd': case 'd':
#ifndef HAVE_REMOVE_OPEN #ifndef HAVE_REMOVE_OPEN
{ {
int index = arg & 7; int index = arg & 7;
for (i = 0; i < sizeof(openindex) / sizeof(openindex[0]); i++) { for (i = 0; i < sizeof(openindex) / sizeof(openindex[0]); i++) {
if (openindex[i] == index) { if (openindex[i] == index) {
break;
}
}
if (i < sizeof(openindex) / sizeof(openindex[0])) {
break; break;
} }
} }
if (i < sizeof(openindex) / sizeof(openindex[0])) {
break;
}
}
#endif #endif
LOGOP(" remove(\"%s\")", filename[arg & 7]); LOGOP(" remove(\"%s\")", filename[arg & 7]);
rc = SPIFFS_remove(FS, filename[arg & 7]); rc = SPIFFS_remove(FS, filename[arg & 7]);
LOGOP(" -> %d\n", rc); LOGOP(" -> %d\n", rc);
break; break;
case 'r': case 'r':
#ifndef HAVE_REMOVE_OPEN #ifndef HAVE_REMOVE_OPEN
{ {
int index = arg & 7; int index = arg & 7;
for (i = 0; i < sizeof(openindex) / sizeof(openindex[0]); i++) { for (i = 0; i < sizeof(openindex) / sizeof(openindex[0]); i++) {
if (openindex[i] == index) { if (openindex[i] == index) {
break;
}
}
if (i < sizeof(openindex) / sizeof(openindex[0])) {
break; break;
} }
} }
if (i < sizeof(openindex) / sizeof(openindex[0])) {
break;
}
}
#endif #endif
LOGOP(" rename(\"%s\", \"%s\")", filename[arg & 7], filename[(arg >> 3) & 7]); LOGOP(" rename(\"%s\", \"%s\")", filename[arg & 7], filename[(arg >> 3) & 7]);
rc = SPIFFS_rename(FS, filename[arg & 7], filename[(arg >> 3) & 7]); rc = SPIFFS_rename(FS, filename[arg & 7], filename[(arg >> 3) & 7]);
LOGOP(" -> %d\n", rc); LOGOP(" -> %d\n", rc);
break; break;
case 'U': case 'U':
ungetc(arg, f); ungetc(arg, f);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
fd[i] = -1; fd[i] = -1;
} }
{ {
#ifdef DO_UNMOUNT #ifdef DO_UNMOUNT
LOGOP(" unmount\n"); LOGOP(" unmount\n");
SPIFFS_unmount(FS); SPIFFS_unmount(FS);
#endif #endif
char *tmpfile = strdup("/tmp/fsdump.XXXXXX"); char *tmpfile = strdup("/tmp/fsdump.XXXXXX");
LOGOP(" cycle and remount\n"); LOGOP(" cycle and remount\n");
close(mkstemp(tmpfile)); close(mkstemp(tmpfile));
fs_store_dump(tmpfile); fs_store_dump(tmpfile);
fs_mount_dump(tmpfile, 0, 0, blocks * block_size, erase_size, block_size, page_size); fs_mount_dump(tmpfile, 0, 0, blocks * block_size, erase_size, block_size, page_size);
unlink(tmpfile); unlink(tmpfile);
free(tmpfile); free(tmpfile);
#ifndef NO_FORCE_CHECK #ifndef NO_FORCE_CHECK
LOGOP(" forcecheck()"); LOGOP(" forcecheck()");
rc = SPIFFS_check(FS);
LOGOP(" -> %d\n", rc);
#endif
}
break;
case 'c':
{
LOGOP(" check()");
rc = SPIFFS_check(FS); rc = SPIFFS_check(FS);
LOGOP(" -> %d\n", rc); LOGOP(" -> %d\n", rc);
ungetc(arg, f); #endif
break;
} }
break;
default: case 'c':
ungetc(arg, f); {
break; LOGOP(" check()");
rc = SPIFFS_check(FS);
LOGOP(" -> %d\n", rc);
ungetc(arg, f);
break;
}
default:
ungetc(arg, f);
break;
} }
} }