diff options
author | 2016-01-08 20:36:01 +0000 | |
---|---|---|
committer | 2016-01-08 20:36:01 +0000 | |
commit | e1dc1cd7bc1251a4531edb93d4b9f9d47cc693c4 (patch) | |
tree | 5117c01246cca1a500f861ea325b86f57597e8ed | |
parent | Zap extraneous SYNOPSIS sections. (diff) | |
download | wireguard-openbsd-e1dc1cd7bc1251a4531edb93d4b9f9d47cc693c4.tar.xz wireguard-openbsd-e1dc1cd7bc1251a4531edb93d4b9f9d47cc693c4.zip |
Handle redirects to _relative_ URIs containing '://', e.g. for archive.org.
From Lauri Tirkkonen, plus tweak to comment. ok jung@
-rw-r--r-- | usr.bin/ftp/fetch.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index bd3a3b3a836..eda0146a553 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.143 2015/10/13 08:53:43 guenther Exp $ */ +/* $OpenBSD: fetch.c,v 1.144 2016/01/08 20:36:01 sthen Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -833,10 +833,15 @@ again: } else if (isredirect && strncasecmp(cp, LOCATION, sizeof(LOCATION) - 1) == 0) { cp += sizeof(LOCATION) - 1; - if (strstr(cp, "://") == NULL) { + /* + * If there is a colon before the first slash, this URI + * is not relative. RFC 3986 4.2 + */ + if (cp[strcspn(cp, ":/")] != ':') { #ifdef SMALL errx(1, "Relative redirect not supported"); #else /* SMALL */ + /* XXX doesn't handle protocol-relative URIs */ if (*cp == '/') { locbase = NULL; cp++; |