mirror of
https://github.com/curl/curl.git
synced 2026-08-25 13:23:33 +03:00
urlapi: make dedotdotify handle leading dots correctly
Paths starting with one or two leading dots but without a following
slash were not handled correctly.
Follow-up to c31dd6631f
Extended test 1395 accordingly with a set of new test string.
Reported by Codex Security
Closes #20974
This commit is contained in:
parent
acb4fcb2ef
commit
3f06e27502
2 changed files with 44 additions and 5 deletions
|
|
@ -37,6 +37,21 @@ static CURLcode test_unit1395(const char *arg)
|
|||
};
|
||||
|
||||
const struct dotdot pairs[] = {
|
||||
{ "/%2f%2e%2e%2f/../a", "/a" },
|
||||
{ "/%2f%2e%2e%2f/../", "/" },
|
||||
{ "/%2f%2e%2e%2f/.", "/%2f%2e%2e%2f/" },
|
||||
{ "/%2f%2e%2e%2f/", "/%2f%2e%2e%2f/" },
|
||||
{ "/%2f%2e%2e%2f", "/%2f%2e%2e%2f" },
|
||||
{ "/%2f%2e%2e%2", "/%2f%2e%2e%2" },
|
||||
{ "/%2f%2e%2e%", "/%2f%2e%2e%" },
|
||||
{ "/%2f%2e%2e", "/%2f%2e%2e" },
|
||||
{ "/%2f%2e%2", "/%2f%2e%2" },
|
||||
{ "/%2f%2e%", "/%2f%2e%" },
|
||||
{ "/%2f%2e", "/%2f%2e" },
|
||||
{ "/%2f%2", "/%2f%2" },
|
||||
{ "/%2f%", "/%2f%" },
|
||||
{ "/%2f", "/%2f" },
|
||||
{ "/%2", "/%2" },
|
||||
{ "%2f%2e%2e%2f/../a", "%2f%2e%2e%2f/a" },
|
||||
{ "%2f%2e%2e%2f/../", "%2f%2e%2e%2f/" },
|
||||
{ "%2f%2e%2e%2f/.", "%2f%2e%2e%2f/" },
|
||||
|
|
@ -108,6 +123,26 @@ static CURLcode test_unit1395(const char *arg)
|
|||
{ "/moo/..", "/" },
|
||||
{ "/..", "/" },
|
||||
{ "/.", "/" },
|
||||
{ "////../a", "///a" },
|
||||
{ "/../../../../../../", "/" },
|
||||
{ "/..//..//", "//" },
|
||||
{ "/.config/../ssh", "/ssh" },
|
||||
{ "/..config/..", "/" },
|
||||
{ "/.../a", "/.../a" },
|
||||
{ "/a/%2E%2e/b", "/b" },
|
||||
{ "/a/%2e./b", "/b" },
|
||||
{ "/a/.%2e/b", "/b" },
|
||||
{ "/%2f..%2f", "/%2f..%2f" },
|
||||
{ "/a/b/.", "/a/b/" },
|
||||
{ "/a/b/..", "/a/" },
|
||||
{ "well-known", "well-known" },
|
||||
{ ".well-known", ".well-known" },
|
||||
{ "..well-known", "..well-known" },
|
||||
{ "...well-known", "...well-known" },
|
||||
{ "....well-known", "....well-known" },
|
||||
{ "%2ewell-known", "%2ewell-known" },
|
||||
{ "%2Ewell-known", "%2Ewell-known" },
|
||||
{ "../.well-known", ".well-known" },
|
||||
};
|
||||
|
||||
for(i = 0; i < CURL_ARRAYSIZE(pairs); i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue