Fix segfault by OOB read on malformed packets (2)

This commit is contained in:
William Robinet 2020-09-03 19:07:21 +02:00
parent cebce341c5
commit 55510f8fb1

View file

@ -242,7 +242,12 @@ static int process_data_segment(conn,handler,p,stream,direction)
long l; long l;
l=p->len - p->tcp->th_off * 4; l=p->len - p->tcp->th_off * 4;
if(l < 0) {
printf("Malformed packet, computed TCP segment size is negative, skipping ...\n");
return(0);
}
if(stream->close){ if(stream->close){
DBG((0,"Rejecting packet received after FIN: %u:%u(%u)", DBG((0,"Rejecting packet received after FIN: %u:%u(%u)",
ntohl(p->tcp->th_seq),ntohl(p->tcp->th_seq+l),l)); ntohl(p->tcp->th_seq),ntohl(p->tcp->th_seq+l),l));