diff --git a/buffer.c b/buffer.c index 19897296..38048d40 100644 --- a/buffer.c +++ b/buffer.c @@ -2382,6 +2382,9 @@ evbuffer_write_iovec(struct evbuffer *buffer, evutil_socket_t fd, } chain = chain->next; } + if (! i) + return 0; + #ifdef _WIN32 { DWORD bytesSent; diff --git a/evdns.c b/evdns.c index ae86fe92..d32ea46c 100644 --- a/evdns.c +++ b/evdns.c @@ -2533,6 +2533,7 @@ evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address) { struct sockaddr_in sin; int res; + memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = address; sin.sin_port = htons(53); sin.sin_family = AF_INET; diff --git a/http.c b/http.c index 7a460275..babcd2d7 100644 --- a/http.c +++ b/http.c @@ -3992,9 +3992,12 @@ bind_socket_ai(struct evutil_addrinfo *ai, int reuse) return (-1); } - setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on)); - if (reuse) - evutil_make_listen_socket_reuseable(fd); + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on))<0) + goto out; + if (reuse) { + if (evutil_make_listen_socket_reuseable(fd) < 0) + goto out; + } if (ai != NULL) { r = bind(fd, ai->ai_addr, (ev_socklen_t)ai->ai_addrlen); diff --git a/listener.c b/listener.c index 6e3594ac..a39c4dfc 100644 --- a/listener.c +++ b/listener.c @@ -227,9 +227,15 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb, if (fd == -1) return NULL; - setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on)); + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void*)&on, sizeof(on))<0) { + evutil_closesocket(fd); + return NULL; + } if (flags & LEV_OPT_REUSEABLE) { - evutil_make_listen_socket_reuseable(fd); + if (evutil_make_listen_socket_reuseable(fd) < 0) { + evutil_closesocket(fd); + return NULL; + } } if (flags & LEV_OPT_DEFERRED_ACCEPT) { diff --git a/test/bench_cascade.c b/test/bench_cascade.c index e9293228..3b8ea9c8 100644 --- a/test/bench_cascade.c +++ b/test/bench_cascade.c @@ -70,8 +70,10 @@ read_cb(evutil_socket_t fd, short which, void *arg) long idx = (long) arg; recv(fd, &ch, sizeof(ch), 0); - if (idx >= 0) - send(idx, "e", 1, 0); + if (idx >= 0) { + if (send(idx, "e", 1, 0) < 0) + perror("send"); + } fired++; } @@ -112,7 +114,8 @@ run_once(int num_pipes) fired = 0; /* kick everything off with a single write */ - send(pipes[1], "e", 1, 0); + if (send(pipes[1], "e", 1, 0) < 0) + perror("send"); event_dispatch(); diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index c13ecb29..affd60d1 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -115,11 +115,12 @@ frob_socket(evutil_socket_t sock) { struct linger l; int one = 1; - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one)); + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one))<0) + perror("setsockopt(SO_REUSEADDR)"); l.l_onoff = 1; l.l_linger = 0; if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0) - perror("setsockopt"); + perror("setsockopt(SO_LINGER)"); } static int diff --git a/test/regress_dns.c b/test/regress_dns.c index cfb32552..fb58a0be 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -1052,7 +1052,6 @@ test_bufferevent_connect_hostname(void *arg) int expect_err5; struct evdns_base *dns=NULL; struct evdns_server_port *port=NULL; - evutil_socket_t server_fd=-1; struct sockaddr_in sin; int listener_port=-1; ev_uint16_t dns_port=0; @@ -1154,8 +1153,6 @@ test_bufferevent_connect_hostname(void *arg) end: if (listener) evconnlistener_free(listener); - if (server_fd>=0) - evutil_closesocket(server_fd); if (port) evdns_close_server_port(port); if (dns) diff --git a/test/regress_et.c b/test/regress_et.c index 7f700cf3..cb3d1ceb 100644 --- a/test/regress_et.c +++ b/test/regress_et.c @@ -104,7 +104,7 @@ test_edgetriggered(void *et) called = was_et = 0; - send(pair[0], test, (int)strlen(test)+1, 0); + tt_int_op(send(pair[0], test, (int)strlen(test)+1, 0), >, 0); shutdown(pair[0], SHUT_WR); /* Initalize the event library */ diff --git a/test/regress_listener.c b/test/regress_listener.c index b2dd0435..4db102df 100644 --- a/test/regress_listener.c +++ b/test/regress_listener.c @@ -162,7 +162,7 @@ regress_listener_error(void *arg) } /* send, so that pair[0] will look 'readable'*/ - send(data->pair[1], "hello", 5, 0); + tt_int_op(send(data->pair[1], "hello", 5, 0), >, 0); /* Start a listener with a bogus socket. */ listener = evconnlistener_new(base, acceptcb, &count, diff --git a/test/regress_ssl.c b/test/regress_ssl.c index c0c20279..6c3489f1 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -108,7 +108,8 @@ getcert(void) name = X509_NAME_new(); tt_assert(name); - tt_assert(NID_undef != (nid = OBJ_txt2nid("commonName"))); + nid = OBJ_txt2nid("commonName"); + tt_assert(NID_undef != nid); tt_assert(0 != X509_NAME_add_entry_by_NID( name, nid, MBSTRING_ASC, (unsigned char*)"example.com", -1, -1, 0)); diff --git a/test/regress_testutils.c b/test/regress_testutils.c index 340bf979..1f004603 100644 --- a/test/regress_testutils.c +++ b/test/regress_testutils.c @@ -178,12 +178,16 @@ regress_dns_server_cb(struct evdns_server_request *req, void *data) return; } else if (!strcmp(tab->anstype, "A")) { struct in_addr in; - evutil_inet_pton(AF_INET, tab->ans, &in); + if (!evutil_inet_pton(AF_INET, tab->ans, &in)) { + TT_DIE(("Bad A value %s in table", tab->ans)); + } evdns_server_request_add_a_reply(req, question, 1, &in.s_addr, 100); } else if (!strcmp(tab->anstype, "AAAA")) { struct in6_addr in6; - evutil_inet_pton(AF_INET6, tab->ans, &in6); + if (!evutil_inet_pton(AF_INET6, tab->ans, &in6)) { + TT_DIE(("Bad AAAA value %s in table", tab->ans)); + } evdns_server_request_add_aaaa_reply(req, question, 1, &in6.s6_addr, 100); } else { diff --git a/test/test-eof.c b/test/test-eof.c index cad67460..9ac4f8d9 100644 --- a/test/test-eof.c +++ b/test/test-eof.c @@ -106,7 +106,8 @@ main(int argc, char **argv) return (1); - send(pair[0], test, (int)strlen(test)+1, 0); + if (send(pair[0], test, (int)strlen(test)+1, 0) < 0) + return (1); shutdown(pair[0], SHUT_WR); /* Initalize the event library */