diff --git a/netwerk/streamconv/converters/ParseFTPList.cpp b/netwerk/streamconv/converters/ParseFTPList.cpp index dce4053b28c..0c49732987c 100644 --- a/netwerk/streamconv/converters/ParseFTPList.cpp +++ b/netwerk/streamconv/converters/ParseFTPList.cpp @@ -84,7 +84,8 @@ int ParseFTPList(const char *line, struct list_state *state, { static const char *month_names = "JanFebMarAprMayJunJulAugSepOctNovDec"; const char *tokens[16]; /* 16 is more than enough */ - unsigned int toklen[16]; + unsigned int toklen[(sizeof(tokens)/sizeof(tokens[0]))]; + unsigned int linelen_sans_wsp; // line length sans whitespace unsigned int numtoks = 0; unsigned int tokmarker = 0; /* extra info for lstyle handler */ unsigned int month_num = 0; @@ -118,6 +119,15 @@ int ParseFTPList(const char *line, struct list_state *state, } } + linelen_sans_wsp = &(tokens[numtoks-1][toklen[numtoks-1]]) - tokens[0]; + if (numtoks == (sizeof(tokens)/sizeof(tokens[0])) ) + { + pos = linelen; + while (pos > 0 && (line[pos-1] == ' ' || line[pos-1] == '\t')) + pos--; + linelen_sans_wsp = pos; + } + /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #if defined(SUPPORT_EPLF) @@ -178,7 +188,7 @@ int ParseFTPList(const char *line, struct list_state *state, state->parsed_one = 1; state->lstyle = lstyle = 'E'; - p = &(tokens[numtoks-1][toklen[numtoks-1]]); + p = &(line[linelen_sans_wsp]); result->fe_fname = tokens[1]; result->fe_fnlen = p - tokens[1]; @@ -748,7 +758,7 @@ int ParseFTPList(const char *line, struct list_state *state, state->parsed_one = 1; state->lstyle = lstyle; - p = &(tokens[numtoks-1][toklen[numtoks-1]]); /* line end sans wsp */ + p = &(line[linelen_sans_wsp]); /* line end sans wsp */ result->fe_cinfs = 1; result->fe_fname = tokens[3]; result->fe_fnlen = p - tokens[3]; @@ -765,19 +775,24 @@ int ParseFTPList(const char *line, struct list_state *state, } else if ((tokens[2][1]) != 'D') /* not