int fuzz_main(const uint8_t *stdin_buf, size_t data_size) { entry_connection_t conn; /* Set up the fake connection */ memset(&conn, 0, sizeof(conn)); conn.edge_.base_.type = CONN_TYPE_AP; conn.edge_.base_.state = AP_CONN_STATE_HTTP_CONNECT_WAIT; conn.socks_request = tor_malloc_zero(sizeof(socks_request_t)); conn.socks_request->listener_type = CONN_TYPE_AP_HTTP_CONNECT_LISTENER; conn.edge_.base_.inbuf = buf_new_with_data((char*)stdin_buf, data_size); if (!conn.edge_.base_.inbuf) { log_debug(LD_GENERAL, "Zero-Length-Input\n"); goto done; } /* Parse the headers */ int rv = connection_ap_process_http_connect(&conn); /* TODO: check the output is correctly parsed based on the input */ log_debug(LD_GENERAL, "Result:\n%d\n", rv); goto done; done: /* Reset. */ socks_request_free(conn.socks_request); buf_free(conn.edge_.base_.inbuf); conn.edge_.base_.inbuf = NULL; return 0; }
static int socks_test_cleanup(const struct testcase_t *testcase, void *ptr) { socks_test_data_t *data = ptr; (void)testcase; buf_free(data->buf); socks_request_free(data->req); tor_free(data); return 1; }