NAT44 segv on unknown proto on inside interface 53/12353/2
authorMatthew Smith <mgsmith@netgate.com>
Mon, 30 Apr 2018 21:39:13 +0000 (16:39 -0500)
committerDamjan Marion <dmarion.lists@gmail.com>
Thu, 3 May 2018 19:07:53 +0000 (19:07 +0000)
commit42ae29a2fe9b12bbbc0c6495b2077252545c9cb9
treeccc68b57c02b12e4bcde7332e15f479fce327b19
parent6f1c48db24b5731176d57121c47040339e6d7f6c
NAT44 segv on unknown proto on inside interface

When a packet with an unknown proto arrives
on an inside interface and there are no existing sessions
for the source address, a segv occurs.

snat_in2out_unknown_proto() finds the head of the sessions
dlist, fetches the address of the next element using
head->next, and then dereferences the next element. On the
first packet received from a source address, head->next is
~0, so this results in a segv.

Check that the session list is not empty before trying to
traverse it.

Also removed unnecessary lookup against tsm->user_hash.
Prior call to nat_user_get_or_create() already performed
that lookup and added a user if one didn't exist.

Change-Id: If73e79aa2f8e3962ab7b876ecf55aea40d7a5472
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
src/plugins/nat/in2out.c