sctp: fix error return code in sctp_sendmsg_new_asoc()
Return error code -EINVAL in the address len check error handling case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()' in the for loop. Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7083a45ad0
commit
d98985dd6c
@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
|
|||||||
struct sctp_association *asoc;
|
struct sctp_association *asoc;
|
||||||
enum sctp_scope scope;
|
enum sctp_scope scope;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
int err = -EINVAL;
|
int err;
|
||||||
|
|
||||||
*tp = NULL;
|
*tp = NULL;
|
||||||
|
|
||||||
@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
|
|||||||
memset(daddr, 0, sizeof(*daddr));
|
memset(daddr, 0, sizeof(*daddr));
|
||||||
dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
|
dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
|
||||||
if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
|
if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
|
||||||
if (dlen < sizeof(struct in_addr))
|
if (dlen < sizeof(struct in_addr)) {
|
||||||
|
err = -EINVAL;
|
||||||
goto free;
|
goto free;
|
||||||
|
}
|
||||||
|
|
||||||
dlen = sizeof(struct in_addr);
|
dlen = sizeof(struct in_addr);
|
||||||
daddr->v4.sin_family = AF_INET;
|
daddr->v4.sin_family = AF_INET;
|
||||||
daddr->v4.sin_port = htons(asoc->peer.port);
|
daddr->v4.sin_port = htons(asoc->peer.port);
|
||||||
memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
|
memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
|
||||||
} else {
|
} else {
|
||||||
if (dlen < sizeof(struct in6_addr))
|
if (dlen < sizeof(struct in6_addr)) {
|
||||||
|
err = -EINVAL;
|
||||||
goto free;
|
goto free;
|
||||||
|
}
|
||||||
|
|
||||||
dlen = sizeof(struct in6_addr);
|
dlen = sizeof(struct in6_addr);
|
||||||
daddr->v6.sin6_family = AF_INET6;
|
daddr->v6.sin6_family = AF_INET6;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user