hurl | Simple gopher and http(s) client. |
| download: http://git.y1.nz/archives/hurl.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 253d3a83fa37c241595e1ccb06332b0d06917443 parent 07d17b2f66f68e86d0858c662b86d4486bb1e817 Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Tue, 18 Dec 2018 18:25:02 +0100 tls_read: check return value correctly the value can be negative, but not neccesarily -1. Noticed on a timeout of some site. Diffstat:
| M | hurl.c | 11 | +++++++---- |
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/hurl.c b/hurl.c @@ -185,6 +185,7 @@ https_request(void) { struct tls *t = NULL; char buf[READ_BUF_SIZ], *p; + const char *errstr; size_t n, len; ssize_t r; int fd = -1, httpok = 0, ret = 1; @@ -227,8 +228,9 @@ https_request(void) string comparison. */ if ((r = tls_read(t, &buf[len], sizeof(buf) - len - 1)) == 0) break; - if (r == -1) { - fprintf(stderr, "tls_read: %s\n", tls_error(t)); + if (r < 0) { + errstr = tls_error(t); + fprintf(stderr, "tls_read: %s\n", errstr ? errstr : ""); goto err; } } @@ -263,8 +265,9 @@ https_request(void) r = tls_read(t, &buf, sizeof(buf)); if (r == 0) break; - if (r == -1) { - fprintf(stderr, "tls_read: %s\n", tls_error(t)); + if (r < 0) { + errstr = tls_error(t); + fprintf(stderr, "tls_read: %s\n", errstr ? errstr : ""); goto err; } len += r;
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.