Skip to contentSkip to conversation

tcp: fix a size_t < 0 comparison in tcp_read_sock

PATCH RESEND Applied Octavian Purdila 2 participants 2 messages Jul 2, 2008 – Jul 3, 2008

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

PATCH RESEND 1/1 tcp: fix a size_t < 0 comparison in tcp_read_sock

Discovered it while testing this patch:

http://www.spinics.net/lists/netdev/msg64668.html

(in this case, tcp_read_sock breaks; but regardless of that patch I think we should have this one)

Thanks,
tavi

commit 6cf0a9254f0b7fc41781a2cacd5a8b312a4b1e70

Author: Octavian Purdila <[email protected]>
Date:   Wed Jul 2 21:25:51 2008 +0300

tcp: fix a size_t < 0 comparison in tcp_read_sock

<used> should be of type int (not size_t) since recv_actor can return negative values and it is also used in a < 0 comparison.

net/ipv4/tcp.c +2 -1
index 850825d..4f91d17 100644
@@ -1208,7 +1208,8 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
 		return -ENOTCONN;
 	while ((skb = tcp_recv_skb(sk, seq, &offset)) != NULL) {
 		if (offset < skb->len) {
-			size_t used, len;
+			int used;
+			size_t len;
 
 			len = skb->len - offset;
 			/* Stop reading if we hit a patch of urgent data */