aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/ftp/ftp_response.erl
diff options
context:
space:
mode:
authorJohan Sommerfeld <[email protected]>2016-10-06 16:57:45 +0200
committerJohan Sommerfeld <[email protected]>2016-10-06 16:57:45 +0200
commit6aba6239e8ab54b8db7ad0b76b1a8870af682d32 (patch)
tree82ddc7a210ba6618d84b24d60433f7261c353751 /lib/inets/src/ftp/ftp_response.erl
parent05be21eb0ad09fcdd63d955ed1d5b50ed34af925 (diff)
downloadotp-6aba6239e8ab54b8db7ad0b76b1a8870af682d32.tar.gz
otp-6aba6239e8ab54b8db7ad0b76b1a8870af682d32.tar.bz2
otp-6aba6239e8ab54b8db7ad0b76b1a8870af682d32.zip
Fix inets ftp bug related to multiple lines resp
Fixes a bug that makes the ftp client end up in bad state if there is a multi line response from the server and the response number is in the message being sent.
Diffstat (limited to 'lib/inets/src/ftp/ftp_response.erl')
-rw-r--r--lib/inets/src/ftp/ftp_response.erl18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/inets/src/ftp/ftp_response.erl b/lib/inets/src/ftp/ftp_response.erl
index 7533bc4550..d54d97dc91 100644
--- a/lib/inets/src/ftp/ftp_response.erl
+++ b/lib/inets/src/ftp/ftp_response.erl
@@ -90,19 +90,23 @@ parse_lines(<<C1, C2, C3, ?WHITE_SPACE, Bin/binary>>, Lines, start) ->
parse_lines(Bin, [?WHITE_SPACE, C3, C2, C1 | Lines], finish);
%% Last line found
-parse_lines(<<C1, C2, C3, ?WHITE_SPACE, Rest/binary>>, Lines, {C1, C2, C3}) ->
- parse_lines(Rest, [?WHITE_SPACE, C3, C2, C1 | Lines], finish);
+parse_lines(<<?CR, ?LF, C1, C2, C3, ?WHITE_SPACE, Rest/binary>>, Lines, {C1, C2, C3}) ->
+ parse_lines(Rest, [?WHITE_SPACE, C3, C2, C1, ?LF, ?CR | Lines], finish);
%% Potential end found wait for more data
-parse_lines(<<C1, C2, C3>> = Bin, Lines, {C1, C2, C3}) ->
+parse_lines(<<?CR, ?LF, C1, C2, C3>> = Bin, Lines, {C1, C2, C3}) ->
{continue, {Bin, Lines, {C1, C2, C3}}};
%% Intermidate line begining with status code
-parse_lines(<<C1, C2, C3, Rest/binary>>, Lines, {C1, C2, C3}) ->
- parse_lines(Rest, [C3, C2, C1 | Lines], {C1, C2, C3});
+parse_lines(<<?CR, ?LF, C1, C2, C3, Rest/binary>>, Lines, {C1, C2, C3}) ->
+ parse_lines(Rest, [C3, C2, C1, ?LF, ?CR | Lines], {C1, C2, C3});
%% Potential last line wait for more data
-parse_lines(<<C1, C2>> = Data, Lines, {C1, C2, _} = StatusCode) ->
+parse_lines(<<?CR, ?LF, C1, C2>> = Data, Lines, {C1, C2, _} = StatusCode) ->
{continue, {Data, Lines, StatusCode}};
-parse_lines(<<C1>> = Data, Lines, {C1, _, _} = StatusCode) ->
+parse_lines(<<?CR, ?LF, C1>> = Data, Lines, {C1, _, _} = StatusCode) ->
+ {continue, {Data, Lines, StatusCode}};
+parse_lines(<<?CR, ?LF>> = Data, Lines, {_,_,_} = StatusCode) ->
+ {continue, {Data, Lines, StatusCode}};
+parse_lines(<<?LF>> = Data, Lines, {_,_,_} = StatusCode) ->
{continue, {Data, Lines, StatusCode}};
parse_lines(<<>> = Data, Lines, {_,_,_} = StatusCode) ->
{continue, {Data, Lines, StatusCode}};