summaryrefslogtreecommitdiff
path: root/src/ocsptool-common.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-26 17:18:44 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-26 17:18:44 +0200
commite58cad6a1473164665f007aba7435e3637884213 (patch)
treec011b61ceaf92ea95b54752c9462f59db989ea2c /src/ocsptool-common.c
parente1369328dd449620edcd6401b495be62f12e956e (diff)
downloadgnutls-e58cad6a1473164665f007aba7435e3637884213.tar.gz
ocsptool: Include path in ocsp request.
This resolves #108582 (https://savannah.gnu.org/support/?108582), reported by Matt McCutchen.
Diffstat (limited to 'src/ocsptool-common.c')
-rw-r--r--src/ocsptool-common.c14
1 files changed, 9 insertions, 5 deletions
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 <ocsptool-common.h>
#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);