case IPOPT_LSRR:
case IPOPT_SSRR:
+ /* Sanity check for option length */
+ if (ptr[off + 1] < 2)
+ {
+ DPRINTF(("ah_massage_headers(): illegal IPv4 option length for option %d\n", ptr[off]));
+ ahstat.ahs_hdrops++;
+ m_freem(m);
+ return EINVAL;
+ }
+
/*
* On output, if we have either of the source routing
* options, we should swap the destination address of
@@ -296,10 +316,10 @@
/* Fall through */
default:
- /* Sanity check for zero-length options */
- if (ptr[off + 1] == 0)
+ /* Sanity check for option length */
+ if (ptr[off + 1] < 2)
{
- DPRINTF(("ah_massage_headers(): illegal zero-length IPv4 option %d\n", ptr[off]));
+ DPRINTF(("ah_massage_headers(): illegal IPv4 option length for option %d\n", ptr[off]));
ahstat.ahs_hdrops++;
m_freem(m);
return EINVAL;