Re: [PATCH] UDPCP Communication Protocol

From: Hagen Paul Pfeifer
Date: Mon Jan 10 2011 - 19:49:34 EST


find_dest() via new_dest() may return NULL

* stefani@xxxxxxxxxxx | 2010-12-31 10:29:45 [+0100]:

>+static int udpcp_sendmsg(struct kiocb *iocb, struct sock *sk,
>+ struct msghdr *msg, size_t len)
>+{
>+ struct inet_sock *inet = inet_sk(sk);
>+ struct udpcp_sock *usk = udpcp_sk(sk);
>+ struct ipcm_cookie *ipc;
>+ struct rtable *rt = NULL;
>+ int free = 0;
>+ int connected = 0;
>+ __be32 daddr, faddr, saddr;
>+ __be16 dport;
>+ u8 tos;
>+ int err = 0;
>+ int corkreq = usk->udpsock.corkflag || msg->msg_flags & MSG_MORE;
>+ int (*getfrag) (void *, char *, int, int, int, struct sk_buff *);
>+ struct udpcp_dest *dest;
>+
>+ if (len > UDPCP_MAX_MSGSIZE)
>+ return -EMSGSIZE;
>+
>+ /*
>+ * Check the flags.
>+ */
>+ if (msg->msg_flags & MSG_OOB)
>+ return -EOPNOTSUPP;
>+
>+ /*
>+ * check if socket is binded to a port
>+ */
>+ if (!(sk->sk_userlocks & SOCK_BINDPORT_LOCK) || !inet->inet_num)
>+ return -ENOTCONN;
>+
>+ /*
>+ * Get and verify the address.
>+ */
>+ if (msg->msg_name) {
>+ struct sockaddr_in *usin = (struct sockaddr_in *)msg->msg_name;
>+ if (msg->msg_namelen < sizeof(*usin))
>+ return -EINVAL;
>+ if (usin->sin_family != AF_INET) {
>+ if (usin->sin_family != AF_UNSPEC)
>+ return -EAFNOSUPPORT;
>+ }
>+
>+ daddr = usin->sin_addr.s_addr;
>+ dport = usin->sin_port;
>+ } else {
>+ if (sk->sk_state != TCP_ESTABLISHED)
>+ return -EDESTADDRREQ;
>+ daddr = inet->inet_daddr;
>+ dport = inet->inet_dport;
>+ /* Open fast path for connected socket.
>+ Route will not be used, if at least one option is set.
>+ */
>+ connected = 1;
>+ }
>+
>+ if (dport == 0)
>+ return -EINVAL;
>+
>+ dest = find_dest(sk, daddr, dport);
if (!dest)
return -ENOBUFS;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/