socketfuzzer.c (honggfuzz-2.4) | : | socketfuzzer.c (honggfuzz-2.5) | ||
---|---|---|---|---|
skipping to change at line 70 | skipping to change at line 70 | |||
/* Return values: | /* Return values: | |||
0: error | 0: error | |||
1: okay | 1: okay | |||
2: target unresponsive | 2: target unresponsive | |||
*/ | */ | |||
int fuzz_waitforSocketFuzzer(run_t* run) { | int fuzz_waitforSocketFuzzer(run_t* run) { | |||
ssize_t ret; | ssize_t ret; | |||
uint8_t buf[16]; | uint8_t buf[16]; | |||
// Wait until the external fuzzer did his thing | // Wait until the external fuzzer did his thing | |||
bzero(buf, 16); | memset(buf, 0, 16); | |||
ret = files_readFromFd(run->global->socketFuzzer.clientSocket, buf, 4); | ret = files_readFromFd(run->global->socketFuzzer.clientSocket, buf, 4); | |||
LOG_D("fuzz_waitforSocketFuzzer: RECV: %s", buf); | LOG_D("fuzz_waitforSocketFuzzer: RECV: %s", buf); | |||
// We dont care what we receive, its just to block here | // We dont care what we receive, its just to block here | |||
if (ret < 0) { | if (ret < 0) { | |||
LOG_E("fuzz_waitforSocketFuzzer: received: %zu", ret); | LOG_E("fuzz_waitforSocketFuzzer: received: %zu", ret); | |||
} | } | |||
if (memcmp(buf, "okay", 4) == 0) { | if (memcmp(buf, "okay", 4) == 0) { | |||
return 1; | return 1; | |||
skipping to change at line 120 | skipping to change at line 120 | |||
} | } | |||
return true; | return true; | |||
} | } | |||
bool setupSocketFuzzer(honggfuzz_t* run) { | bool setupSocketFuzzer(honggfuzz_t* run) { | |||
int s, len; | int s, len; | |||
socklen_t t; | socklen_t t; | |||
struct sockaddr_un local, remote; | struct sockaddr_un local, remote; | |||
char socketPath[512]; | char socketPath[512]; | |||
snprintf(socketPath, sizeof(socketPath), "/tmp/honggfuzz_socket.%i", getpid( )); | snprintf(socketPath, sizeof(socketPath), "/tmp/honggfuzz_socket.%i", (int)ge tpid()); | |||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { | if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { | |||
perror("socket"); | perror("socket"); | |||
return false; | return false; | |||
} | } | |||
local.sun_family = AF_UNIX; | local.sun_family = AF_UNIX; | |||
strcpy(local.sun_path, socketPath); | strcpy(local.sun_path, socketPath); | |||
unlink(local.sun_path); | unlink(local.sun_path); | |||
len = strlen(local.sun_path) + sizeof(local.sun_family); | len = strlen(local.sun_path) + sizeof(local.sun_family); | |||
skipping to change at line 157 | skipping to change at line 157 | |||
} | } | |||
run->socketFuzzer.serverSocket = s; | run->socketFuzzer.serverSocket = s; | |||
printf("A SocketFuzzer client connected. Continuing.\n"); | printf("A SocketFuzzer client connected. Continuing.\n"); | |||
return true; | return true; | |||
} | } | |||
void cleanupSocketFuzzer() { | void cleanupSocketFuzzer() { | |||
char socketPath[512]; | char socketPath[512]; | |||
snprintf(socketPath, sizeof(socketPath), "/tmp/honggfuzz_socket.%i", getpid( )); | snprintf(socketPath, sizeof(socketPath), "/tmp/honggfuzz_socket.%i", (int)ge tpid()); | |||
unlink(socketPath); | unlink(socketPath); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |