diff options
author | Sverker Eriksson <sverker@erlang.org> | 2011-11-28 15:14:14 +0100 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2011-12-06 11:06:44 +0100 |
commit | dc5f7190f16cf4552db74fba3f4e0f2d654e2594 (patch) | |
tree | 6f9b947d7e4bf228cfe40e22dac45add6f9bd6ff /erts/emulator/beam/packet_parser.c | |
parent | 5984409d1264871cbe61bfec875de53e51713efb (diff) | |
download | otp-dc5f7190f16cf4552db74fba3f4e0f2d654e2594.tar.gz otp-dc5f7190f16cf4552db74fba3f4e0f2d654e2594.tar.bz2 otp-dc5f7190f16cf4552db74fba3f4e0f2d654e2594.zip |
erts: Remove truncation of http packet parsing and return error instead
This is a slight modification of previous commit by Steve Vinoski
For backward compatibility of old users of decode_packet, I think it's enough
to return error instead of keeping the old line truncation behaviour.
Diffstat (limited to 'erts/emulator/beam/packet_parser.c')
-rw-r--r-- | erts/emulator/beam/packet_parser.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/erts/emulator/beam/packet_parser.c b/erts/emulator/beam/packet_parser.c index 8c1662dc6f..4d4b6ea196 100644 --- a/erts/emulator/beam/packet_parser.c +++ b/erts/emulator/beam/packet_parser.c @@ -405,18 +405,22 @@ int packet_get_length(enum PacketParseType htype, const char* ptr1 = ptr; int len = plen; + if (!max_plen) { + /* This is for backward compatibility with old user of decode_packet + * that might use option 'line_length' to limit accepted length of + * http lines. + */ + max_plen = trunc_len; + } + while (1) { const char* ptr2 = memchr(ptr1, '\n', len); if (ptr2 == NULL) { if (max_plen != 0) { - if (n > max_plen) /* packet full */ + if (n >= max_plen) /* packet full */ goto error; } - else if (n >= trunc_len && trunc_len!=0) { /* buffer full */ - plen = trunc_len; - goto done; - } goto more; } else { @@ -425,8 +429,6 @@ int packet_get_length(enum PacketParseType htype, if (*statep == 0) { if (max_plen != 0 && plen > max_plen) goto error; - if (plen >= trunc_len && trunc_len != 0) - plen = trunc_len; goto done; } @@ -439,18 +441,12 @@ int packet_get_length(enum PacketParseType htype, else { if (max_plen != 0 && plen > max_plen) goto error; - if (plen >= trunc_len && trunc_len != 0) - plen = trunc_len; goto done; } } else { if (max_plen != 0 && plen > max_plen) goto error; - if (plen >= trunc_len && trunc_len != 0) { - plen = trunc_len; - goto done; - } goto more; } } |