libc sctp: fix sctp_getladdrs() for 64-bit BE platforms
When calling getsockopt() with SCTP_GET_LOCAL_ADDR_SIZE, use a pointer to a 32-bit variable, since this is what the kernel expects. While there, do some cleanups. MFC after: 1 week
This commit is contained in:
parent
a01b8859cb
commit
dabd8bf914
@ -391,23 +391,23 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
|
||||
{
|
||||
struct sctp_getaddresses *addrs;
|
||||
struct sockaddr *sa;
|
||||
sctp_assoc_t asoc;
|
||||
caddr_t lim;
|
||||
socklen_t opt_len;
|
||||
uint32_t size_of_addresses;
|
||||
int cnt;
|
||||
|
||||
if (raddrs == NULL) {
|
||||
errno = EFAULT;
|
||||
return (-1);
|
||||
}
|
||||
asoc = id;
|
||||
opt_len = (socklen_t)sizeof(sctp_assoc_t);
|
||||
/* When calling getsockopt(), the value contains the assoc_id. */
|
||||
size_of_addresses = (uint32_t)id;
|
||||
opt_len = (socklen_t)sizeof(uint32_t);
|
||||
if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE,
|
||||
&asoc, &opt_len) != 0) {
|
||||
&size_of_addresses, &opt_len) != 0) {
|
||||
return (-1);
|
||||
}
|
||||
/* size required is returned in 'asoc' */
|
||||
opt_len = (socklen_t)((size_t)asoc + sizeof(struct sctp_getaddresses));
|
||||
opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses));
|
||||
addrs = calloc(1, (size_t)opt_len);
|
||||
if (addrs == NULL) {
|
||||
errno = ENOMEM;
|
||||
@ -446,10 +446,10 @@ int
|
||||
sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
|
||||
{
|
||||
struct sctp_getaddresses *addrs;
|
||||
caddr_t lim;
|
||||
struct sockaddr *sa;
|
||||
size_t size_of_addresses;
|
||||
caddr_t lim;
|
||||
socklen_t opt_len;
|
||||
uint32_t size_of_addresses;
|
||||
int cnt;
|
||||
|
||||
if (raddrs == NULL) {
|
||||
@ -457,7 +457,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
|
||||
return (-1);
|
||||
}
|
||||
size_of_addresses = 0;
|
||||
opt_len = (socklen_t)sizeof(int);
|
||||
opt_len = (socklen_t)sizeof(uint32_t);
|
||||
if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE,
|
||||
&size_of_addresses, &opt_len) != 0) {
|
||||
errno = ENOMEM;
|
||||
@ -467,7 +467,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
|
||||
errno = ENOTCONN;
|
||||
return (-1);
|
||||
}
|
||||
opt_len = (socklen_t)(size_of_addresses + sizeof(struct sctp_getaddresses));
|
||||
opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses));
|
||||
addrs = calloc(1, (size_t)opt_len);
|
||||
if (addrs == NULL) {
|
||||
errno = ENOMEM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user