]> Zhao Yanbai Git Server - minix.git/commitdiff
inet: detect short TCP option lengths 96/2896/1
authorDavid van Moolenbroek <david@minix3.org>
Tue, 18 Nov 2014 12:45:46 +0000 (12:45 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Tue, 18 Nov 2014 12:53:18 +0000 (12:53 +0000)
Previously, a TCP option length of zero would cause inet to end up
in an infinite loop.

This resolves #7, reported by Alejandro Hernandez.

Change-Id: I45ad4c789d10d8e202cf6e140a7b9db7a6543c75

minix/net/inet/generic/tcp_lib.c

index a25671beb2f89187c6b97652793e198518e2e65d..0306e6d3ab6fc8e2dfa6601fb76e752dedd92aee 100644 (file)
@@ -90,6 +90,8 @@ size_t *mssp;
                if (i+2 > tcp_hdr_len)
                        break;  /* No length field */
                len= cp[1];
+               if (len < 2)
+                       break;  /* Length too short */
                if (i+len > tcp_hdr_len)
                        break;  /* Truncated option */
                i += len;