Move code out of asserts
@@ -165,13 +165,19 @@ void *upstream_thread(void *arg)
char rbuf[1 * 1024 * 1024];
snprintf(path, sizeof(path), "/%s/_.sock", dirname);
int sd = socket(AF_UNIX, SOCK_STREAM, 0);
- assert(sd >= 0);
+ if (sd < 0) {
+ abort();
+ }
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
- assert(bind(sd, (struct sockaddr *)&addr, sizeof(addr)) == 0);
- assert(listen(sd, 100) == 0);
+ if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
+ abort();
+ }
+ if (listen(sd, 100) != 0) {
+ abort();
+ }
while (1) {
struct sockaddr_un caddr;
@@ -287,7 +293,9 @@ static int create_accepted(int sfd, char *buf, size_t len, pthread_barrier_t **b
/* Create an HTTP[/2] client that will send the fuzzed request */
fd = feeder(sfd, buf, len, barrier);
- assert(fd >= 0);
+ if (fd < 0) {
+ abort();
+ }
/* Pass the server socket to h2o and invoke request processing */
sock = h2o_evloop_socket_create(ctx.loop, fd, H2O_SOCKET_FLAG_IS_ACCEPTED_CONNECTION);
@@ -350,8 +358,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
hostconf = h2o_config_register_host(&config, h2o_iovec_init(H2O_STRLIT(unix_listener)), 65535);
register_handler(hostconf, "/chunked-test", chunked_test);
h2o_url_parse(unix_listener, strlen(unix_listener), &upstream);
- void h2o_proxy_register_reverse_proxy(h2o_pathconf_t * pathconf, h2o_url_t * upstream, h2o_proxy_config_vars_t * config);
- h2o_proxy_register_reverse_proxy(h2o_config_register_path(hostconf, "/reproxy-test", 0), &upstream, &proxy_config);
+ h2o_proxy_register_reverse_proxy(h2o_config_register_path(hostconf, "/reproxy-test", 0), &upstream, 1, &proxy_config);
h2o_file_register(h2o_config_register_path(hostconf, "/", 0), "./examples/doc_root", NULL, NULL, 0);
loop = h2o_evloop_create();
@@ -361,9 +368,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
accept_ctx.hosts = config.hosts;
/* Create a thread to act as the HTTP client */
- assert(socketpair(AF_UNIX, SOCK_STREAM, 0, job_queue) == 0);
- assert(pthread_create(&twriter, NULL, writer_thread, (void *)(long)job_queue[1]) == 0);
- assert(pthread_create(&tupstream, NULL, upstream_thread, dirname) == 0);
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, job_queue) != 0) {
+ abort();
+ }
+ if (pthread_create(&twriter, NULL, writer_thread, (void *)(long)job_queue[1]) != 0) {
+ abort();
+ }
+ if (pthread_create(&tupstream, NULL, upstream_thread, dirname) != 0) {
+ abort();
+ }
init_done = 1;
}
