1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 20:24:26 +01:00

Fixed IP total length zero bug.

This commit is contained in:
Matias Fontanini
2014-11-25 22:49:05 -08:00
parent bcd8cc58f7
commit ae135bb035
2 changed files with 417 additions and 3 deletions

View File

@@ -110,8 +110,10 @@ IP::IP(const uint8_t *buffer, uint32_t total_sz)
}
uint8_t padding = _options_size % 4;
_padded_options_size = padding ? (_options_size - padding + 4) : _options_size;
// check this line PLX
total_sz = std::min(total_sz, (uint32_t)tot_len());
// Don't avoid consuming more than we should if tot_len is 0,
// since this is the case when using TCP segmentation offload
if (tot_len() != 0)
total_sz = std::min(total_sz, (uint32_t)tot_len());
if (total_sz < head_len() * sizeof(uint32_t))
throw malformed_packet();
total_sz -= head_len() * sizeof(uint32_t);