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

Function sockargs

freebsd/kern/uipc_syscalls.c:1526–1562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1524#endif /* COMPAT_OLDSOCK */
1525
1526static int
1527sockargs(struct mbuf **mp, char *buf, socklen_t buflen, int type)
1528{
1529 struct sockaddr *sa;
1530 struct mbuf *m;
1531 int error;
1532
1533 if (buflen > MLEN) {
1534#ifdef COMPAT_OLDSOCK
1535 if (type == MT_SONAME && buflen <= 112 &&
1536 SV_CURPROC_FLAG(SV_AOUT))
1537 buflen = MLEN; /* unix domain compat. hack */
1538 else
1539#endif
1540 if (buflen > MCLBYTES)
1541 return (EINVAL);
1542 }
1543 m = m_get2(buflen, M_WAITOK, type, 0);
1544 m->m_len = buflen;
1545 error = copyin(buf, mtod(m, void *), buflen);
1546 if (error != 0)
1547 (void) m_free(m);
1548 else {
1549 *mp = m;
1550 if (type == MT_SONAME) {
1551 sa = mtod(m, struct sockaddr *);
1552
1553#if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
1554 if (sa->sa_family == 0 && sa->sa_len < AF_MAX &&
1555 SV_CURPROC_FLAG(SV_AOUT))
1556 sa->sa_family = sa->sa_len;
1557#endif
1558 sa->sa_len = buflen;
1559 }
1560 }
1561 return (error);
1562}
1563
1564int
1565getsockaddr(struct sockaddr **namp, const struct sockaddr *uaddr, size_t len)

Callers 1

senditFunction · 0.85

Calls 3

m_get2Function · 0.85
copyinFunction · 0.50
m_freeFunction · 0.50

Tested by

no test coverage detected