diff options
author | Pale Moon <git-repo@palemoon.org> | 2018-01-28 17:35:14 +0100 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2018-01-29 10:44:57 +0100 |
commit | bbe2747866c4b319c531ffda615cce313364913f (patch) | |
tree | 9352c5ffde0a6021976fab6b5d60555b2e341f18 | |
parent | 245bee383c22b629e276768c101dfd854266ac51 (diff) | |
download | palemoon-bbe2747866c4b319c531ffda615cce313364913f.tar.gz |
Use CheckedInt to compute guess for the location of -> in FTP parser.
-rw-r--r-- | netwerk/streamconv/converters/ParseFTPList.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/netwerk/streamconv/converters/ParseFTPList.cpp b/netwerk/streamconv/converters/ParseFTPList.cpp index 227d4d83d..9048f5afa 100644 --- a/netwerk/streamconv/converters/ParseFTPList.cpp +++ b/netwerk/streamconv/converters/ParseFTPList.cpp @@ -10,9 +10,12 @@ #include "plstr.h" #include "nsDebug.h" #include "prprf.h" +#include "mozilla/CheckedInt.h" /* ==================================================================== */ +using mozilla::CheckedInt; + static inline int ParsingFailed(struct list_state *state) { if (state->parsed_one || state->lstyle) /* junk if we fail to parse */ @@ -1183,14 +1186,17 @@ int ParseFTPList(const char *line, struct list_state *state, { /* First try to use result->fe_size to find " -> " sequence. This can give proper result for cases like "aaa -> bbb -> ccc". */ - uint32_t fe_size = atoi(result->fe_size); + uintptr_t fe_size = atoi(result->fe_size); + CheckedInt<uintptr_t> arrow_start(result->fe_fnlen); + arrow_start -= fe_size; + arrow_start -= 4; - if (result->fe_fnlen > (fe_size + 4) && - PL_strncmp(result->fe_fname + result->fe_fnlen - fe_size - 4 , " -> ", 4) == 0) + if (arrow_start.isValid() && + PL_strncmp(result->fe_fname + arrow_start.value(), " -> ", 4) == 0) { result->fe_lname = result->fe_fname + (result->fe_fnlen - fe_size); result->fe_lnlen = (&(line[linelen])) - (result->fe_lname); - result->fe_fnlen -= fe_size + 4; + result->fe_fnlen = arrow_start.value(); } else { |