1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-27 09:59:04 +00:00

Fix off-by-one issue in last change. Fixes #2107

This commit is contained in:
dmiller
2020-08-24 17:07:47 +00:00
parent 7d6cf3ae0c
commit 428c3e7700

View File

@@ -1365,14 +1365,14 @@ static bool validateTCPhdr(const u8 *tcpc, unsigned len) {
optlen = hdrlen - sizeof(struct tcp_hdr); optlen = hdrlen - sizeof(struct tcp_hdr);
#define OPTLEN_IS(expected) do { \ #define OPTLEN_IS(expected) do { \
if (expected == 0 || optlen < (expected) || hdrlen != (expected)) \ if ((expected) == 0 || optlen < (expected) || hdrlen != (expected)) \
return false; \ return false; \
optlen -= (expected); \ optlen -= (expected); \
tcpc += (expected) - 1; \ tcpc += (expected); \
} while(0); } while(0);
while (optlen > 0) { while (optlen > 0) {
hdrlen = *++tcpc; hdrlen = *(tcpc + 1);
switch (*tcpc) { switch (*tcpc) {
case 0: // EOL case 0: // EOL
/* Options processing is over. */ /* Options processing is over. */