Skip to content

Commit 72dc1b6

Browse files
committed
Tighten URL parsing in OCSP_parse_url
1 parent 443d7f7 commit 72dc1b6

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

crypto/ocsp/ocsp_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
162162

163163
// Set default ports for http and https. If a port is specified later, this
164164
// will be overwritten. |pssl| will be set to true, if https is being used.
165-
if (strncmp(buffer, "https", 5) == 0) {
165+
if (strcmp(buffer, "https") == 0) {
166166
*pssl = 1;
167167
port = (char *)"443";
168-
} else if (strncmp(buffer, "http", 4) == 0) {
168+
} else if (strcmp(buffer, "http") == 0) {
169169
*pssl = 0;
170170
port = (char *)"80";
171171
} else {

crypto/ocsp/ocsp_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,13 @@ static const OCSPURLTestVector kOCSPURLVectors[] = {
16041604
// No closing bracket for ipv6.
16051605
{"http://[2001:db8::1/", nullptr, nullptr, nullptr, 0,
16061606
OCSP_URL_PARSE_ERROR},
1607+
// Protocol must match exactly, not just as a prefix.
1608+
{"https1://ocsp.example.com/", nullptr, nullptr, nullptr, 0,
1609+
OCSP_URL_PARSE_ERROR},
1610+
{"httpss://ocsp.example.com/", nullptr, nullptr, nullptr, 0,
1611+
OCSP_URL_PARSE_ERROR},
1612+
{"httpe://ocsp.example.com/path", nullptr, nullptr, nullptr, 0,
1613+
OCSP_URL_PARSE_ERROR},
16071614
};
16081615

16091616
class OCSPURLTest : public testing::TestWithParam<OCSPURLTestVector> {};

0 commit comments

Comments
 (0)