Skip to contentSkip to conversation

sctp: fix the length check in sctp_getsockopt_maxburst()

PATCH New Wei Yongjun 1 participant 1 message Feb 20, 2009

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

PATCH 1/1 sctp: fix the length check in sctp_getsockopt_maxburst()

The code in sctp_getsockopt_maxburst() doesn't allow len to be larger then struct sctp_assoc_value, which is a common case where app writers just pass down the sizeof(buf) or something similar.

This patch fix the problem.

---
 net/sctp/socket.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/sctp/socket.c +2 -1
index 5ab68f9..fe0b40c 100644
@@ -5287,7 +5287,8 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
 		printk(KERN_WARNING
 		   "SCTP: Use struct sctp_assoc_value instead\n");
 		params.assoc_id = 0;
-	} else if (len = sizeof (struct sctp_assoc_value)) {
+	} else if (len >= sizeof(struct sctp_assoc_value)) {
+		len = sizeof(struct sctp_assoc_value);
 		if (copy_from_user(&params, optval, len))
 			return -EFAULT;
 	} else
Signature · 1 line
1.5.3.8