diff options
author | 2021-03-18 14:08:01 +0000 | |
---|---|---|
committer | 2021-03-18 14:08:01 +0000 | |
commit | 5d2a5cd687f41a7c526553b2238200dce3ffba8b (patch) | |
tree | 5a6d9f126122e1c8a866ad9c040ff44db5a5314f | |
parent | Initialize rsyncpid and httppid in the noop case. It seem gcc is not able (diff) | |
download | wireguard-openbsd-5d2a5cd687f41a7c526553b2238200dce3ffba8b.tar.xz wireguard-openbsd-5d2a5cd687f41a7c526553b2238200dce3ffba8b.zip |
Do not assign the return value from asprintf (int) to a size_t and then
compare it to -1. Instead use a temp variable and assign to bufsz after
the -1 check.
Also add errx() calls after the switch statements in the FSM functions.
OK job@ tb@
-rw-r--r-- | usr.sbin/rpki-client/http.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c index 867fe2fe29d..6746990e11a 100644 --- a/usr.sbin/rpki-client/http.c +++ b/usr.sbin/rpki-client/http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http.c,v 1.5 2021/03/04 15:44:13 tb Exp $ */ +/* $OpenBSD: http.c,v 1.6 2021/03/18 14:08:01 claudio Exp $ */ /* * Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com> * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.com> @@ -596,7 +596,7 @@ static int http_request(struct http_connection *conn) { char *host, *epath, *modified_since; - int with_port = 0; + int r, with_port = 0; /* TODO adjust request for HTTP proxy setups */ @@ -634,7 +634,7 @@ http_request(struct http_connection *conn) free(conn->buf); conn->bufpos = 0; - if ((conn->bufsz = asprintf(&conn->buf, + if ((r = asprintf(&conn->buf, "GET /%s HTTP/1.1\r\n" "Connection: close\r\n" "User-Agent: " HTTP_USER_AGENT "\r\n" @@ -642,6 +642,7 @@ http_request(struct http_connection *conn) epath, host, modified_since ? modified_since : "")) == -1) err(1, NULL); + conn->bufsz = r; free(epath); free(host); @@ -1032,6 +1033,7 @@ http_handle(struct http_connection *conn) case STATE_FREE: errx(1, "bad http state"); } + errx(1, "unknown http state"); } static int @@ -1084,6 +1086,7 @@ http_nextstep(struct http_connection *conn) case STATE_FREE: errx(1, "bad http state"); } + errx(1, "unknown http state"); } static int |