diff options
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 15 |
1 files changed, 7 insertions, 8 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 | ||