diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-11-30 16:20:26 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-12-03 12:25:44 +0100 |
commit | 1cafe4fc33c1dae7dd5024f600475fa96637b128 (patch) | |
tree | b3c21e5ed659e224bc8e093ba9799822e6947cd0 /crypto/http | |
parent | acf1651de1ba36e79176d9df0943698ed5bcee9c (diff) |
parse_http_line1(): Fix diagnostic output on error and return code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17171)
(cherry picked from commit e2b7dc353b353efccd1d228f743baa7c2d2f9f49)
Diffstat (limited to 'crypto/http')
-rw-r--r-- | crypto/http/http_client.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index e5c8bcd33d..f1e2b25a28 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -369,12 +369,13 @@ static OSSL_HTTP_REQ_CTX *http_req_ctx_new(int free_wbio, BIO *wbio, BIO *rbio, /* * Parse first HTTP response line. This should be like this: "HTTP/1.0 200 OK". - * We need to obtain the numeric code and (optional) informational message. + * We need to obtain the status code and (optional) informational message. + * Return any received HTTP response status code, or 0 on fatal error. */ static int parse_http_line1(char *line, int *found_keep_alive) { - int i, retcode; + int i, retcode, err; char *code, *reason, *end; if (!HAS_PREFIX(line, HTTP_PREFIX_VERSION)) @@ -430,22 +431,21 @@ static int parse_http_line1(char *line, int *found_keep_alive) case HTTP_STATUS_CODE_FOUND: return retcode; default: + err = HTTP_R_RECEIVED_ERROR; if (retcode < 400) - retcode = HTTP_R_STATUS_CODE_UNSUPPORTED; - else - retcode = HTTP_R_RECEIVED_ERROR; + err = HTTP_R_STATUS_CODE_UNSUPPORTED; if (*reason == '\0') - ERR_raise_data(ERR_LIB_HTTP, retcode, "code=%s", code); + ERR_raise_data(ERR_LIB_HTTP, err, "code=%s", code); else - ERR_raise_data(ERR_LIB_HTTP, retcode, - "code=%s, reason=%s", code, reason); - return 0; + ERR_raise_data(ERR_LIB_HTTP, err, "code=%s, reason=%s", code, + reason); + return retcode; } err: - i = 0; - while (i < 60 && ossl_isprint(line[i])) - i++; + for (i = 0; i < 60 && line[i] != '\0'; i++) + if (!ossl_isprint(line[i])) + line[i] = ' '; line[i] = '\0'; ERR_raise_data(ERR_LIB_HTTP, HTTP_R_HEADER_PARSE_ERROR, "content=%s", line); return 0; |