aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_sockglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ip_sockglue.c')
-rw-r--r--net/ipv4/ip_sockglue.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index fffcc130900e..82f341e84fae 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -148,19 +148,17 @@ static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb)
148 148
149static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb) 149static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb)
150{ 150{
151 __be16 _ports[2], *ports;
151 struct sockaddr_in sin; 152 struct sockaddr_in sin;
152 __be16 *ports;
153 int end;
154
155 end = skb_transport_offset(skb) + 4;
156 if (end > 0 && !pskb_may_pull(skb, end))
157 return;
158 153
159 /* All current transport protocols have the port numbers in the 154 /* All current transport protocols have the port numbers in the
160 * first four bytes of the transport header and this function is 155 * first four bytes of the transport header and this function is
161 * written with this assumption in mind. 156 * written with this assumption in mind.
162 */ 157 */
163 ports = (__be16 *)skb_transport_header(skb); 158 ports = skb_header_pointer(skb, skb_transport_offset(skb),
159 sizeof(_ports), &_ports);
160 if (!ports)
161 return;
164 162
165 sin.sin_family = AF_INET; 163 sin.sin_family = AF_INET;
166 sin.sin_addr.s_addr = ip_hdr(skb)->daddr; 164 sin.sin_addr.s_addr = ip_hdr(skb)->daddr;