summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2008-08-08 08:51:22 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2008-08-08 08:51:22 +0000
commit924a7ff7faa7300916e6bb1bc330a2ab4abd69f4 (patch)
tree99ca82e953da7e4a0bedbb8f5ef70865eb6f428a
parentbbc0041d77729a4313493f1f7efd97049630d0e0 (diff)
Check gettimeofday() against -1; Add a missing error check in one place.
OK reyk@
-rw-r--r--usr.sbin/relayd/check_icmp.c4
-rw-r--r--usr.sbin/relayd/hce.c6
-rw-r--r--usr.sbin/relayd/pfe.c4
-rw-r--r--usr.sbin/relayd/relay.c18
-rw-r--r--usr.sbin/relayd/relay_udp.c12
-rw-r--r--usr.sbin/relayd/relayd.c4
6 files changed, 27 insertions, 21 deletions
diff --git a/usr.sbin/relayd/check_icmp.c b/usr.sbin/relayd/check_icmp.c
index c022077f936..f5518582f63 100644
--- a/usr.sbin/relayd/check_icmp.c
+++ b/usr.sbin/relayd/check_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: check_icmp.c,v 1.24 2008/07/19 10:52:32 reyk Exp $ */
+/* $OpenBSD: check_icmp.c,v 1.25 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -93,7 +93,7 @@ check_icmp_add(struct ctl_icmp_event *cie, int flags, struct timeval *start,
if (start != NULL)
bcopy(start, &cie->tv_start, sizeof(cie->tv_start));
bcopy(&cie->env->sc_timeout, &tv, sizeof(tv));
- if (gettimeofday(&cie->tv_start, NULL))
+ if (gettimeofday(&cie->tv_start, NULL) == -1)
fatal("check_icmp_add: gettimeofday");
event_del(&cie->ev);
event_set(&cie->ev, cie->s, EV_TIMEOUT|flags, fn, cie);
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index b6aa6599ac5..e3bf9dde475 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.43 2008/07/19 11:38:54 reyk Exp $ */
+/* $OpenBSD: hce.c,v 1.44 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -224,7 +224,7 @@ hce_launch_checks(int fd, short event, void *arg)
}
}
- if (gettimeofday(&tv, NULL))
+ if (gettimeofday(&tv, NULL) == -1)
fatal("hce_launch_checks: gettimeofday");
TAILQ_FOREACH(table, env->sc_tables, entry) {
@@ -307,7 +307,7 @@ hce_notify_done(struct host *host, const char *msg)
else
logopt = RELAYD_OPT_LOGNOTIFY;
- if (gettimeofday(&tv_now, NULL))
+ if (gettimeofday(&tv_now, NULL) == -1)
fatal("hce_notify_done: gettimeofday");
timersub(&tv_now, &host->cte.tv_start, &tv_dur);
if (timercmp(&host->cte.tv_start, &tv_dur, >))
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index 9b07926d405..947de05f50b 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.50 2008/07/19 11:38:54 reyk Exp $ */
+/* $OpenBSD: pfe.c,v 1.51 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -946,7 +946,7 @@ pfe_statistics(int fd, short events, void *arg)
u_long cnt;
timerclear(&tv);
- if (gettimeofday(&tv_now, NULL))
+ if (gettimeofday(&tv_now, NULL) == -1)
fatal("pfe_statistics: gettimeofday");
TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index f1dc6b066c4..b2f774fe8db 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.95 2008/07/22 23:17:37 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.96 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -518,7 +518,7 @@ relay_statistics(int fd, short events, void *arg)
*/
timerclear(&tv);
- if (gettimeofday(&tv_now, NULL))
+ if (gettimeofday(&tv_now, NULL) == -1)
fatal("relay_init: gettimeofday");
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) {
@@ -845,7 +845,7 @@ relay_write(struct bufferevent *bev, void *arg)
{
struct ctl_relay_event *cre = (struct ctl_relay_event *)arg;
struct session *con = (struct session *)cre->con;
- if (gettimeofday(&con->se_tv_last, NULL))
+ if (gettimeofday(&con->se_tv_last, NULL) == -1)
con->se_done = 1;
if (con->se_done)
relay_close(con, "last write (done)");
@@ -876,7 +876,7 @@ relay_read(struct bufferevent *bev, void *arg)
struct session *con = (struct session *)cre->con;
struct evbuffer *src = EVBUFFER_INPUT(bev);
- if (gettimeofday(&con->se_tv_last, NULL))
+ if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto done;
if (!EVBUFFER_LENGTH(src))
return;
@@ -1138,7 +1138,7 @@ relay_read_httpcontent(struct bufferevent *bev, void *arg)
struct evbuffer *src = EVBUFFER_INPUT(bev);
size_t size;
- if (gettimeofday(&con->se_tv_last, NULL))
+ if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto done;
size = EVBUFFER_LENGTH(src);
DPRINTF("relay_read_httpcontent: size %d, to read %d",
@@ -1175,7 +1175,7 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
long lval;
size_t size;
- if (gettimeofday(&con->se_tv_last, NULL))
+ if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto done;
size = EVBUFFER_LENGTH(src);
DPRINTF("relay_read_httpchunks: size %d, to read %d",
@@ -1269,7 +1269,7 @@ relay_read_http(struct bufferevent *bev, void *arg)
const char *errstr;
size_t size;
- if (gettimeofday(&con->se_tv_last, NULL))
+ if (gettimeofday(&con->se_tv_last, NULL) == -1)
goto done;
size = EVBUFFER_LENGTH(src);
DPRINTF("relay_read_http: size %d, to read %d", size, cre->toread);
@@ -1926,7 +1926,7 @@ relay_accept(int fd, short sig, void *arg)
con->se_out.dir = RELAY_DIR_RESPONSE;
con->se_retry = rlay->rl_conf.dstretry;
con->se_bnds = -1;
- if (gettimeofday(&con->se_tv_start, NULL))
+ if (gettimeofday(&con->se_tv_start, NULL) == -1)
goto err;
bcopy(&con->se_tv_start, &con->se_tv_last, sizeof(con->se_tv_last));
bcopy(&ss, &con->se_in.ss, sizeof(con->se_in.ss));
@@ -2188,7 +2188,7 @@ relay_connect(struct session *con)
struct relay *rlay = (struct relay *)con->se_relay;
int bnds = -1, ret;
- if (gettimeofday(&con->se_tv_start, NULL))
+ if (gettimeofday(&con->se_tv_start, NULL) == -1)
return (-1);
if (rlay->rl_dsttable != NULL) {
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index d6eeca6fbd5..fc1ee0538d8 100644
--- a/usr.sbin/relayd/relay_udp.c
+++ b/usr.sbin/relayd/relay_udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_udp.c,v 1.16 2008/07/23 10:05:18 reyk Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.17 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -257,7 +257,13 @@ relay_udp_server(int fd, short sig, void *arg)
con->se_in.dir = RELAY_DIR_REQUEST;
con->se_out.dir = RELAY_DIR_RESPONSE;
con->se_retry = rlay->rl_conf.dstretry;
- gettimeofday(&con->se_tv_start, NULL);
+
+ if (gettimeofday(&con->se_tv_start, NULL) == -1) {
+ free(con);
+ free(priv);
+ return;
+ }
+
bcopy(&con->se_tv_start, &con->se_tv_last, sizeof(con->se_tv_last));
bcopy(&ss, &con->se_in.ss, sizeof(con->se_in.ss));
con->se_out.port = rlay->rl_conf.dstport;
@@ -466,7 +472,7 @@ relay_dns_request(struct session *con)
if (debug)
relay_dns_log(con, buf, len);
- if (gettimeofday(&con->se_tv_start, NULL))
+ if (gettimeofday(&con->se_tv_start, NULL) == -1)
return (-1);
if (rlay->rl_dsttable != NULL) {
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index accff773de0..70c846d7e98 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.79 2008/07/22 23:17:37 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.80 2008/08/08 08:51:21 thib Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -910,7 +910,7 @@ event_again(struct event *ev, int fd, short event,
{
struct timeval tv_next, tv_now, tv;
- if (gettimeofday(&tv_now, NULL))
+ if (gettimeofday(&tv_now, NULL) == -1)
fatal("event_again: gettimeofday");
bcopy(end, &tv_next, sizeof(tv_next));