diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 15:49:07 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 15:49:07 +0000 |
commit | e51eba4928e92d7d77981c1b8b48b65c1dd6df22 (patch) | |
tree | b5a12836c6c6ed110e4afa8fe19e2c0e5b936818 /net | |
parent | f516a7e2637774d118a4acaeff3ab12aa4ab8893 (diff) | |
download | chromium_src-e51eba4928e92d7d77981c1b8b48b65c1dd6df22.zip chromium_src-e51eba4928e92d7d77981c1b8b48b65c1dd6df22.tar.gz chromium_src-e51eba4928e92d7d77981c1b8b48b65c1dd6df22.tar.bz2 |
Apply compatibility fixes for FTP LIST parsing code.
TEST=none
BUG=21770,21771
Review URL: http://codereview.chromium.org/214043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26812 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/third_party/parseftp/ParseFTPList.cpp | 11 | ||||
-rw-r--r-- | net/third_party/parseftp/bugfixes.patch | 38 |
2 files changed, 47 insertions, 2 deletions
diff --git a/net/third_party/parseftp/ParseFTPList.cpp b/net/third_party/parseftp/ParseFTPList.cpp index 6cfb6e6..002e705 100644 --- a/net/third_party/parseftp/ParseFTPList.cpp +++ b/net/third_party/parseftp/ParseFTPList.cpp @@ -126,6 +126,9 @@ int ParseFTPList(const char *line, struct list_state *state, } } + if (!numtoks) + return (state->parsed_one || state->lstyle) ? '?' : '"'; + linelen_sans_wsp = &(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[0]; if (numtoks == (sizeof(tokens)/sizeof(tokens[0])) ) { @@ -358,11 +361,15 @@ int ParseFTPList(const char *line, struct list_state *state, pos++; p++; } - if (lstyle && pos < (toklen[0]-1) && *p == ']') + if (lstyle && pos < (toklen[0]-1)) { + /* ']' was found and there is at least one character after it */ pos++; p++; tokmarker = pos; /* length of leading "[DIR1.DIR2.etc]" */ + } else { + /* not a CMU style listing */ + lstyle = 0; } } while (lstyle && pos < toklen[0] && *p != ';') @@ -389,7 +396,7 @@ int ParseFTPList(const char *line, struct list_state *state, pos -= tokmarker; /* => fnlength sans "[DIR1.DIR2.etc]" */ p = &(tokens[0][tokmarker]); /* offset of basename */ - if (!lstyle || pos > 80) /* VMS filenames can't be longer than that */ + if (!lstyle || pos == 0 || pos > 80) /* VMS filenames can't be longer than that */ { lstyle = 0; } diff --git a/net/third_party/parseftp/bugfixes.patch b/net/third_party/parseftp/bugfixes.patch new file mode 100644 index 0000000..eec7185 --- /dev/null +++ b/net/third_party/parseftp/bugfixes.patch @@ -0,0 +1,38 @@ +--- ParseFTPList.cpp ++++ ParseFTPList.cpp +@@ -126,6 +126,9 @@ int ParseFTPList(const char *line, struct list_state *state, + } + } + ++ if (!numtoks) ++ return (state->parsed_one || state->lstyle) ? '?' : '"'; ++ + linelen_sans_wsp = &(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[0]; + if (numtoks == (sizeof(tokens)/sizeof(tokens[0])) ) + { +@@ -358,11 +361,15 @@ int ParseFTPList(const char *line, struct list_state *state, + pos++; + p++; + } +- if (lstyle && pos < (toklen[0]-1) && *p == ']') ++ if (lstyle && pos < (toklen[0]-1)) + { ++ /* ']' was found and there is at least one character after it */ + pos++; + p++; + tokmarker = pos; /* length of leading "[DIR1.DIR2.etc]" */ ++ } else { ++ /* not a CMU style listing */ ++ lstyle = 0; + } + } + while (lstyle && pos < toklen[0] && *p != ';') +@@ -389,7 +396,7 @@ int ParseFTPList(const char *line, struct list_state *state, + pos -= tokmarker; /* => fnlength sans "[DIR1.DIR2.etc]" */ + p = &(tokens[0][tokmarker]); /* offset of basename */ + +- if (!lstyle || pos > 80) /* VMS filenames can't be longer than that */ ++ if (!lstyle || pos == 0 || pos > 80) /* VMS filenames can't be longer than that */ + { + lstyle = 0; + } |