diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-03 11:37:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-09-03 11:38:15 -0400 |
commit | 270b4f030a07a0ff3ad80e4ae5495ad89b4096ef (patch) | |
tree | 795d5af274317b57a954a64b320b71226f9f1862 /src/or/directory.c | |
parent | 5327605caa5863ec9593fd0899425cd971a9d525 (diff) | |
download | tor-270b4f030a07a0ff3ad80e4ae5495ad89b4096ef.tar.gz tor-270b4f030a07a0ff3ad80e4ae5495ad89b4096ef.zip |
Handle HTTP minor versions greater than 9
(In practice they don't exist, but so long as we're making changes for
standards compliance...)
Also add several more unit tests for good and bad URL types.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 58ce0cf838..099df50d07 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1417,10 +1417,16 @@ parse_http_url(const char *headers, char **url) } /* Check if the header is well formed (next sequence - * should be HTTP/1.X\r\n). Assumes we're supporting 1.0? */ + * should be HTTP/1.X\r\n). Assumes we're supporting 1.0? */ char *e = (char *)eat_whitespace_no_nl(s); - if (strcmpstart(e, "HTTP/1.") || !(*(e+8) == '\r')) { - return -1; + { + unsigned minor_ver; + char ch; + if (2 != tor_sscanf(e, "HTTP/1.%u%c", &minor_ver, &ch)) { + return -1; + } + if (ch != '\r') + return -1; } if (s-start < 5 || strcmpstart(start,"/tor/")) { /* need to rewrite it */ |