Skip to content

Commit

Permalink
[DECNet] fib: Fix out of bound access of dn_fib_props[]
Browse files Browse the repository at this point in the history
Fixes a typo which caused fib_props[] to have the wrong size
and makes sure the value used to index the array which is
provided by userspace via netlink is checked to avoid out of
bound access.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Graf authored and David S. Miller committed Mar 26, 2007
1 parent a0ee18b commit a979101
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/decnet/dn_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static struct
{
int error;
u8 scope;
} dn_fib_props[RTA_MAX+1] = {
} dn_fib_props[RTN_MAX+1] = {
[RTN_UNSPEC] = { .error = 0, .scope = RT_SCOPE_NOWHERE },
[RTN_UNICAST] = { .error = 0, .scope = RT_SCOPE_UNIVERSE },
[RTN_LOCAL] = { .error = 0, .scope = RT_SCOPE_HOST },
Expand Down Expand Up @@ -276,6 +276,9 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta
struct dn_fib_info *ofi;
int nhs = 1;

if (r->rtm_type > RTN_MAX)
goto err_inval;

if (dn_fib_props[r->rtm_type].scope > r->rtm_scope)
goto err_inval;

Expand Down

0 comments on commit a979101

Please sign in to comment.