diff options
Diffstat (limited to 'net/third_party/parseftp')
-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; + } |