diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-11 02:06:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-07-11 02:06:43 -0400 |
commit | 3be550f34b03e5eb762f74d447ebbeba97efbd6d (patch) | |
tree | 07881880089af5f9d8dbea1444f09e34a0100ef1 /net/ipv4 | |
parent | dffe4f048b420f1af0b10a6090add0c5ea69e585 (diff) |
[UDP]: Fix length check.
RĂ©mi Denis-Courmont wrote:
> Right. By the way, shouldn't "len" rather be signed in there?
>
> unsigned int len;
>
> /* if we're overly short, let UDP handle it */
> len = skb->len - sizeof(struct udphdr);
> if (len <= 0)
> goto udp;
It should, but the < 0 case can't happen since __udp4_lib_rcv
already makes sure that we have at least a complete UDP header.
Anyways, this patch fixes it.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/udp.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 4ec4a25a8d0c..28355350fb62 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -951,14 +951,10 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
951 | * >0 if skb should be passed on to UDP. | 951 | * >0 if skb should be passed on to UDP. |
952 | * <0 if skb should be resubmitted as proto -N | 952 | * <0 if skb should be resubmitted as proto -N |
953 | */ | 953 | */ |
954 | unsigned int len; | ||
955 | 954 | ||
956 | /* if we're overly short, let UDP handle it */ | 955 | /* if we're overly short, let UDP handle it */ |
957 | len = skb->len - sizeof(struct udphdr); | 956 | if (skb->len > sizeof(struct udphdr) && |
958 | if (len <= 0) | 957 | up->encap_rcv != NULL) { |
959 | goto udp; | ||
960 | |||
961 | if (up->encap_rcv != NULL) { | ||
962 | int ret; | 958 | int ret; |
963 | 959 | ||
964 | ret = (*up->encap_rcv)(sk, skb); | 960 | ret = (*up->encap_rcv)(sk, skb); |
@@ -971,7 +967,6 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
971 | /* FALLTHROUGH -- it's a UDP Packet */ | 967 | /* FALLTHROUGH -- it's a UDP Packet */ |
972 | } | 968 | } |
973 | 969 | ||
974 | udp: | ||
975 | /* | 970 | /* |
976 | * UDP-Lite specific tests, ignored on UDP sockets | 971 | * UDP-Lite specific tests, ignored on UDP sockets |
977 | */ | 972 | */ |