MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getsockaddr

Function getsockaddr

freebsd/kern/uipc_syscalls.c:1564–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1562}
1563
1564int
1565getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)
1566{
1567 struct sockaddr *sa;
1568 int error;
1569
1570 if (len > SOCK_MAXADDRLEN)
1571 return (ENAMETOOLONG);
1572 if (len < offsetof(struct sockaddr, sa_data[0]))
1573 return (EINVAL);
1574 sa = malloc(len, M_SONAME, M_WAITOK);
1575 error = copyin(uaddr, sa, len);
1576 if (error != 0) {
1577 free(sa, M_SONAME);
1578 } else {
1579#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
1580 if (sa->sa_family == 0 && sa->sa_len < AF_MAX &&
1581 SV_CURPROC_FLAG(SV_AOUT))
1582 sa->sa_family = sa->sa_len;
1583#endif
1584 sa->sa_len = len;
1585 *namp = sa;
1586 }
1587 return (error);
1588}
1589
1590/*
1591 * Dispose of externalized rights from an SCM_RIGHTS message. This function

Callers 7

sys_sctp_generic_sendmsgFunction · 0.85
sys_bindFunction · 0.85
sys_bindatFunction · 0.85
sys_connectFunction · 0.85
sys_connectatFunction · 0.85
senditFunction · 0.85

Calls 3

mallocFunction · 0.85
freeFunction · 0.70
copyinFunction · 0.50

Tested by

no test coverage detected