Commit 2cc925c
committed
Check NBT packet length before full Scapy dissection
Parse the 4-byte NBT header to get the payload length before
attempting full packet dissection. This fixes two issues:
1. Incomplete packets (TCP fragmentation) are handled cleanly
by returning 0, without hitting the exception path at all.
2. Malformed packets now consume exactly their declared size
(nbt_length + 4) instead of len(data), which could eat the
start of the next valid packet in the same TCP segment.1 parent 7748fec commit 2cc925c
1 file changed
+10
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
442 | 451 | | |
443 | 452 | | |
444 | 453 | | |
| |||
448 | 457 | | |
449 | 458 | | |
450 | 459 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 460 | + | |
456 | 461 | | |
457 | 462 | | |
458 | 463 | | |
| |||
0 commit comments