提交 8ec1d9be 编写于 作者: A Alexander Aring 提交者: Marcel Holtmann

6lowpan: iphc: use sizeof in udp uncompression

Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 84ca5e03
...@@ -271,27 +271,31 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) ...@@ -271,27 +271,31 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
if (!uh) if (!uh)
goto err; goto err;
fail = lowpan_fetch_skb(skb, &tmp, 1); fail = lowpan_fetch_skb(skb, &tmp, sizeof(tmp));
if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) { if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) {
pr_debug("UDP header uncompression\n"); pr_debug("UDP header uncompression\n");
switch (tmp & LOWPAN_NHC_UDP_CS_P_11) { switch (tmp & LOWPAN_NHC_UDP_CS_P_11) {
case LOWPAN_NHC_UDP_CS_P_00: case LOWPAN_NHC_UDP_CS_P_00:
fail |= lowpan_fetch_skb(skb, &uh->source, 2); fail |= lowpan_fetch_skb(skb, &uh->source,
fail |= lowpan_fetch_skb(skb, &uh->dest, 2); sizeof(uh->source));
fail |= lowpan_fetch_skb(skb, &uh->dest,
sizeof(uh->dest));
break; break;
case LOWPAN_NHC_UDP_CS_P_01: case LOWPAN_NHC_UDP_CS_P_01:
fail |= lowpan_fetch_skb(skb, &uh->source, 2); fail |= lowpan_fetch_skb(skb, &uh->source,
fail |= lowpan_fetch_skb(skb, &val, 1); sizeof(uh->source));
fail |= lowpan_fetch_skb(skb, &val, sizeof(val));
uh->dest = htons(val + LOWPAN_NHC_UDP_8BIT_PORT); uh->dest = htons(val + LOWPAN_NHC_UDP_8BIT_PORT);
break; break;
case LOWPAN_NHC_UDP_CS_P_10: case LOWPAN_NHC_UDP_CS_P_10:
fail |= lowpan_fetch_skb(skb, &val, 1); fail |= lowpan_fetch_skb(skb, &val, sizeof(val));
uh->source = htons(val + LOWPAN_NHC_UDP_8BIT_PORT); uh->source = htons(val + LOWPAN_NHC_UDP_8BIT_PORT);
fail |= lowpan_fetch_skb(skb, &uh->dest, 2); fail |= lowpan_fetch_skb(skb, &uh->dest,
sizeof(uh->dest));
break; break;
case LOWPAN_NHC_UDP_CS_P_11: case LOWPAN_NHC_UDP_CS_P_11:
fail |= lowpan_fetch_skb(skb, &val, 1); fail |= lowpan_fetch_skb(skb, &val, sizeof(val));
uh->source = htons(LOWPAN_NHC_UDP_4BIT_PORT + uh->source = htons(LOWPAN_NHC_UDP_4BIT_PORT +
(val >> 4)); (val >> 4));
uh->dest = htons(LOWPAN_NHC_UDP_4BIT_PORT + uh->dest = htons(LOWPAN_NHC_UDP_4BIT_PORT +
...@@ -311,7 +315,8 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) ...@@ -311,7 +315,8 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
pr_debug_ratelimited("checksum elided currently not supported\n"); pr_debug_ratelimited("checksum elided currently not supported\n");
goto err; goto err;
} else { } else {
fail |= lowpan_fetch_skb(skb, &uh->check, 2); fail |= lowpan_fetch_skb(skb, &uh->check,
sizeof(uh->check));
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册