From: Dan Carpenter Date: Wed, 7 Dec 2011 20:49:38 +0000 (+0000) Subject: sock_diag: off by one checks X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6f8e4ad0eff5117ba895122674670f9c63b6e8d8;p=openwrt%2Fstaging%2Fblogic.git sock_diag: off by one checks These tests are off by one because sock_diag_handlers[] only has AF_MAX elements. Signed-off-by: Dan Carpenter Acked-by: Pavel Emelyanov Signed-off-by: David S. Miller --- diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c index fbaf01ce12f2..9c27bcda59be 100644 --- a/net/core/sock_diag.c +++ b/net/core/sock_diag.c @@ -32,7 +32,7 @@ int sock_diag_register(struct sock_diag_handler *hndl) { int err = 0; - if (hndl->family > AF_MAX) + if (hndl->family >= AF_MAX) return -EINVAL; mutex_lock(&sock_diag_table_mutex); @@ -50,7 +50,7 @@ void sock_diag_unregister(struct sock_diag_handler *hnld) { int family = hnld->family; - if (family > AF_MAX) + if (family >= AF_MAX) return; mutex_lock(&sock_diag_table_mutex);