[NETFILTER]: ebtables: don't compute gap before checking struct type

We cannot compute the gap until we know we have a 'struct ebt_entry' and
not 'struct ebt_entries'. Failure to check can cause crash.

Tested-by: Santiago Garcia Mantinan <manty@manty.net>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Chuck Ebbert and committed by David S. Miller 44f9a2fd bbdc176a

+2 -1
+2 -1
net/bridge/netfilter/ebtables.c
··· 610 610 struct ebt_entry_target *t; 611 611 struct ebt_target *target; 612 612 unsigned int i, j, hook = 0, hookmask = 0; 613 - size_t gap = e->next_offset - e->target_offset; 613 + size_t gap; 614 614 int ret; 615 615 616 616 /* don't mess with the struct ebt_entries */ ··· 660 660 if (ret != 0) 661 661 goto cleanup_watchers; 662 662 t = (struct ebt_entry_target *)(((char *)e) + e->target_offset); 663 + gap = e->next_offset - e->target_offset; 663 664 target = find_target_lock(t->u.name, &ret, &ebt_mutex); 664 665 if (!target) 665 666 goto cleanup_watchers;