Skip to contentSkip to conversation

sock_diag: off by one checks

PATCH Applied Dan Carpenter 3 participants 4 messages Dec 8, 2011 – Dec 9, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sock_diag: off by one checks

These tests are off by one because sock_diag_handlers[] only has AF_MAX elements.

net/core/sock_diag.c +2 -2
index fbaf01c..9c27bcd 100644
@@ -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);
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Dan Carpenter

These tests are off by one because sock_diag_handlers[] only has AF_MAX elements.

Oops :(

Quoted 1 line
Quoted 23 lines
net/core/sock_diag.c +2 -2
index fbaf01c..9c27bcd 100644
@@ -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);