diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/udp.c | 15 | ||||
-rw-r--r-- | net/ipv6/udp.c | 15 |
2 files changed, 14 insertions, 16 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 4f7d2122d818..608a5446d05b 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1117,7 +1117,7 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
1117 | struct inet_sock *inet = inet_sk(sk); | 1117 | struct inet_sock *inet = inet_sk(sk); |
1118 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; | 1118 | struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; |
1119 | struct sk_buff *skb; | 1119 | struct sk_buff *skb; |
1120 | unsigned int ulen, copied; | 1120 | unsigned int ulen; |
1121 | int peeked; | 1121 | int peeked; |
1122 | int err; | 1122 | int err; |
1123 | int is_udplite = IS_UDPLITE(sk); | 1123 | int is_udplite = IS_UDPLITE(sk); |
@@ -1138,10 +1138,9 @@ try_again: | |||
1138 | goto out; | 1138 | goto out; |
1139 | 1139 | ||
1140 | ulen = skb->len - sizeof(struct udphdr); | 1140 | ulen = skb->len - sizeof(struct udphdr); |
1141 | copied = len; | 1141 | if (len > ulen) |
1142 | if (copied > ulen) | 1142 | len = ulen; |
1143 | copied = ulen; | 1143 | else if (len < ulen) |
1144 | else if (copied < ulen) | ||
1145 | msg->msg_flags |= MSG_TRUNC; | 1144 | msg->msg_flags |= MSG_TRUNC; |
1146 | 1145 | ||
1147 | /* | 1146 | /* |
@@ -1150,14 +1149,14 @@ try_again: | |||
1150 | * coverage checksum (UDP-Lite), do it before the copy. | 1149 | * coverage checksum (UDP-Lite), do it before the copy. |
1151 | */ | 1150 | */ |
1152 | 1151 | ||
1153 | if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { | 1152 | if (len < ulen || UDP_SKB_CB(skb)->partial_cov) { |
1154 | if (udp_lib_checksum_complete(skb)) | 1153 | if (udp_lib_checksum_complete(skb)) |
1155 | goto csum_copy_err; | 1154 | goto csum_copy_err; |
1156 | } | 1155 | } |
1157 | 1156 | ||
1158 | if (skb_csum_unnecessary(skb)) | 1157 | if (skb_csum_unnecessary(skb)) |
1159 | err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), | 1158 | err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), |
1160 | msg->msg_iov, copied); | 1159 | msg->msg_iov, len); |
1161 | else { | 1160 | else { |
1162 | err = skb_copy_and_csum_datagram_iovec(skb, | 1161 | err = skb_copy_and_csum_datagram_iovec(skb, |
1163 | sizeof(struct udphdr), | 1162 | sizeof(struct udphdr), |
@@ -1186,7 +1185,7 @@ try_again: | |||
1186 | if (inet->cmsg_flags) | 1185 | if (inet->cmsg_flags) |
1187 | ip_cmsg_recv(msg, skb); | 1186 | ip_cmsg_recv(msg, skb); |
1188 | 1187 | ||
1189 | err = copied; | 1188 | err = len; |
1190 | if (flags & MSG_TRUNC) | 1189 | if (flags & MSG_TRUNC) |
1191 | err = ulen; | 1190 | err = ulen; |
1192 | 1191 | ||
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 34efb3589ffa..a7af9d68cd6c 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -322,7 +322,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
322 | struct ipv6_pinfo *np = inet6_sk(sk); | 322 | struct ipv6_pinfo *np = inet6_sk(sk); |
323 | struct inet_sock *inet = inet_sk(sk); | 323 | struct inet_sock *inet = inet_sk(sk); |
324 | struct sk_buff *skb; | 324 | struct sk_buff *skb; |
325 | unsigned int ulen, copied; | 325 | unsigned int ulen; |
326 | int peeked; | 326 | int peeked; |
327 | int err; | 327 | int err; |
328 | int is_udplite = IS_UDPLITE(sk); | 328 | int is_udplite = IS_UDPLITE(sk); |
@@ -341,10 +341,9 @@ try_again: | |||
341 | goto out; | 341 | goto out; |
342 | 342 | ||
343 | ulen = skb->len - sizeof(struct udphdr); | 343 | ulen = skb->len - sizeof(struct udphdr); |
344 | copied = len; | 344 | if (len > ulen) |
345 | if (copied > ulen) | 345 | len = ulen; |
346 | copied = ulen; | 346 | else if (len < ulen) |
347 | else if (copied < ulen) | ||
348 | msg->msg_flags |= MSG_TRUNC; | 347 | msg->msg_flags |= MSG_TRUNC; |
349 | 348 | ||
350 | is_udp4 = (skb->protocol == htons(ETH_P_IP)); | 349 | is_udp4 = (skb->protocol == htons(ETH_P_IP)); |
@@ -355,14 +354,14 @@ try_again: | |||
355 | * coverage checksum (UDP-Lite), do it before the copy. | 354 | * coverage checksum (UDP-Lite), do it before the copy. |
356 | */ | 355 | */ |
357 | 356 | ||
358 | if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) { | 357 | if (len < ulen || UDP_SKB_CB(skb)->partial_cov) { |
359 | if (udp_lib_checksum_complete(skb)) | 358 | if (udp_lib_checksum_complete(skb)) |
360 | goto csum_copy_err; | 359 | goto csum_copy_err; |
361 | } | 360 | } |
362 | 361 | ||
363 | if (skb_csum_unnecessary(skb)) | 362 | if (skb_csum_unnecessary(skb)) |
364 | err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), | 363 | err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), |
365 | msg->msg_iov, copied ); | 364 | msg->msg_iov,len); |
366 | else { | 365 | else { |
367 | err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); | 366 | err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); |
368 | if (err == -EINVAL) | 367 | if (err == -EINVAL) |
@@ -411,7 +410,7 @@ try_again: | |||
411 | datagram_recv_ctl(sk, msg, skb); | 410 | datagram_recv_ctl(sk, msg, skb); |
412 | } | 411 | } |
413 | 412 | ||
414 | err = copied; | 413 | err = len; |
415 | if (flags & MSG_TRUNC) | 414 | if (flags & MSG_TRUNC) |
416 | err = ulen; | 415 | err = ulen; |
417 | 416 | ||