From e58cad6a1473164665f007aba7435e3637884213 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 26 May 2014 17:18:44 +0200 Subject: ocsptool: Include path in ocsp request. This resolves #108582 (https://savannah.gnu.org/support/?108582), reported by Matt McCutchen. --- src/ocsptool-common.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ocsptool-common.c b/src/ocsptool-common.c index 9404865ce5..2e7a359aeb 100644 --- a/src/ocsptool-common.c +++ b/src/ocsptool-common.c @@ -37,7 +37,7 @@ #include #define MAX_BUF 4*1024 -#define HEADER_PATTERN "POST / HTTP/1.1\r\n" \ +#define HEADER_PATTERN "POST /%s HTTP/1.1\r\n" \ "Host: %s\r\n" \ "Accept: */*\r\n" \ "Content-Type: application/ocsp-request\r\n" \ @@ -46,18 +46,21 @@ static char buffer[MAX_BUF + 1]; /* returns the host part of a URL */ -static const char *host_from_url(const char *url, unsigned int *port) +static const char *host_from_url(const char *url, unsigned int *port, const char **path) { static char hostname[512]; char *p; *port = 0; + *path = ""; if ((p = strstr(url, "http://")) != NULL) { snprintf(hostname, sizeof(hostname), "%s", p + 7); p = strchr(hostname, '/'); - if (p != NULL) + if (p != NULL) { *p = 0; + *path = p+1; + } p = strchr(hostname, ':'); if (p != NULL) { @@ -143,6 +146,7 @@ int send_ocsp_request(const char *server, char service[16]; unsigned char *p; const char *hostname; + const char *path = ""; unsigned int headers_size = 0, port; socket_st hd; @@ -175,7 +179,7 @@ int send_ocsp_request(const char *server, gnutls_free(data.data); } - hostname = host_from_url(url, &port); + hostname = host_from_url(url, &port, &path); if (port != 0) snprintf(service, sizeof(service), "%u", port); else @@ -187,7 +191,7 @@ int send_ocsp_request(const char *server, _generate_request(cert, issuer, &req, nonce); - snprintf(headers, sizeof(headers), HEADER_PATTERN, hostname, + snprintf(headers, sizeof(headers), HEADER_PATTERN, path, hostname, (unsigned int) req.size); headers_size = strlen(headers); -- cgit v1.2.1