| version 1.289, 2010/07/19 14:09:45 |
version 1.290, 2010/11/05 00:21:51 |
|
|
| * If offset or IP_MF are set, must reassemble. |
* If offset or IP_MF are set, must reassemble. |
| */ |
*/ |
| if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
if (ip->ip_off & ~htons(IP_DF|IP_RF)) { |
| struct mbuf *m_final; |
|
| u_int off, flen; |
|
| bool mff; |
|
| |
|
| /* |
|
| * Prevent TCP blind data attacks by not allowing non-initial |
|
| * fragments to start at less than 68 bytes (minimal fragment |
|
| * size) and making sure the first fragment is at least 68 |
|
| * bytes. |
|
| */ |
|
| off = (ntohs(ip->ip_off) & IP_OFFMASK) << 3; |
|
| if ((off > 0 ? off + hlen : len) < IP_MINFRAGSIZE - 1) { |
|
| IP_STATINC(IP_STAT_BADFRAGS); |
|
| goto bad; |
|
| } |
|
| |
|
| /* Fragment length and MF flag. */ |
|
| flen = ntohs(ip->ip_len) - hlen; |
|
| mff = (ip->ip_off & htons(IP_MF)) != 0; |
|
| if (mff) { |
|
| /* |
|
| * Make sure that fragments have a data length |
|
| * which is non-zero and multiple of 8 bytes. |
|
| */ |
|
| if (flen == 0 || (flen & 0x7) != 0) { |
|
| IP_STATINC(IP_STAT_BADFRAGS); |
|
| goto bad; |
|
| } |
|
| } |
|
| |
|
| /* |
|
| * Adjust total IP length to not reflect header and convert |
|
| * offset of this to bytes. XXX: clobbers struct ip. |
|
| */ |
|
| ip->ip_len = htons(flen); |
|
| ip->ip_off = htons(off); |
|
| |
|
| /* |
/* |
| * Pass to IP reassembly mechanism. |
* Pass to IP reassembly mechanism. |
| */ |
*/ |
| if (ip_reass_packet(m, ip, mff, &m_final) != 0) { |
if (ip_reass_packet(&m, ip) != 0) { |
| /* Failed; invalid fragment(s) or packet. */ |
/* Failed; invalid fragment(s) or packet. */ |
| goto bad; |
goto bad; |
| } |
} |
| if (m_final == NULL) { |
if (m == NULL) { |
| /* More fragments should come; silently return. */ |
/* More fragments should come; silently return. */ |
| return; |
return; |
| } |
} |
| /* Reassembly is done, we have the final packet. */ |
/* |
| m = m_final; |
* Reassembly is done, we have the final packet. |
| |
* Updated cached data in local variable(s). |
| /* Updated local variable(s). */ |
*/ |
| ip = mtod(m, struct ip *); |
ip = mtod(m, struct ip *); |
| hlen = ip->ip_hl << 2; |
hlen = ip->ip_hl << 2; |
| } |
} |