diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-11-23 23:09:18 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-11-23 23:09:18 -0800 |
| commit | 5ea2a1845f3393e91d6d102a8a89f339dd24f467 (patch) | |
| tree | d17d6cd87d1a540e50f2e996924d8e1c92e1c8f0 /src/supplemental/http | |
| parent | d1218d7309475193b53911667911c4f59a1a7752 (diff) | |
| download | nng-5ea2a1845f3393e91d6d102a8a89f339dd24f467.tar.gz nng-5ea2a1845f3393e91d6d102a8a89f339dd24f467.tar.bz2 nng-5ea2a1845f3393e91d6d102a8a89f339dd24f467.zip | |
fixes #1358 nni_strtou64 and nni_strtox64 could be replaced with strtoull
Diffstat (limited to 'src/supplemental/http')
| -rw-r--r-- | src/supplemental/http/http_client.c | 5 | ||||
| -rw-r--r-- | src/supplemental/http/http_server.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c index 36446b63..c6f5167a 100644 --- a/src/supplemental/http/http_client.c +++ b/src/supplemental/http/http_client.c @@ -10,6 +10,7 @@ // #include <stdbool.h> +#include <stdlib.h> #include <string.h> #include "core/nng_impl.h" @@ -257,6 +258,7 @@ http_txn_cb(void *arg) { http_txn * txn = arg; const char * str; + char * end; int rv; uint64_t len; nni_iov iov; @@ -306,7 +308,8 @@ http_txn_cb(void *arg) if ((nni_strcasecmp(str, "HEAD") == 0) || ((str = nni_http_res_get_header( txn->res, "Content-Length")) == NULL) || - (nni_strtou64(str, &len) != 0) || (len == 0)) { + ((len = (uint64_t) strtoull(str, &end, 10)) == 0) || + (end == NULL) || (*end != '\0')) { // If no content-length, or HEAD (which per RFC // never transfers data), then we are done. http_txn_finish_aios(txn, 0); diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c index 49c236e4..e1f51e52 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -704,8 +704,10 @@ http_sconn_rxdone(void *arg) if ((h->getbody) && ((cls = nni_http_req_get_header(req, "Content-Length")) != NULL)) { uint64_t len; + char *end; - if ((nni_strtou64(cls, &len) != 0) || (len > h->maxbody)) { + len = strtoull(cls, &end, 10); + if ((end == NULL) || (*end != '\0') || (len > h->maxbody)) { nni_mtx_unlock(&s->mtx); http_sconn_error(sc, NNG_HTTP_STATUS_BAD_REQUEST); return; |
