- Fix incorrect error return on sctp_getaddrlen

- Fix a memory leak when a non v4/v6 address was passed in.
- Take out strange line that copy's back to the src array
  incorrectly (corrupting the input array).

Approved by:	re(bmah@freebsd.org)
Obtained from:	Weongyo Jeong(weongyo.jeong@gmail.com)
This commit is contained in:
Randall Stewart 2007-06-22 13:59:54 +00:00
parent 671d309c7c
commit a593094ea0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170993

View File

@ -152,14 +152,14 @@ sctp_getaddrlen(sa_family_t family)
sd = socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP);
#endif
if (sd == -1) {
return (errno);
return (-1);
}
error = getsockopt(sd, IPPROTO_SCTP, SCTP_GET_ADDR_LEN, &av, &siz);
close(sd);
if (error == 0) {
return ((int)av.assoc_value);
} else {
return (error);
return (-1);
}
}
@ -256,8 +256,8 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags)
for (i = 0; i < addrcnt; i++) {
sz = sa->sa_len;
fam = sa->sa_family;
((struct sockaddr_in *)&addrs[i])->sin_port = ((struct sockaddr_in *)sa)->sin_port;
if ((fam != AF_INET) && (fam != AF_INET6)) {
free(gaddrs);
errno = EINVAL;
return (-1);
}