1/*-
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 19 unchanged lines hidden (view full) ---
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/uipc_syscalls.c 176498 2008-02-24 00:07:00Z cperciva $");
37
38#include "opt_sctp.h"
39#include "opt_compat.h"
40#include "opt_ktrace.h"
41#include "opt_mac.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
--- 655 unchanged lines hidden (view full) ---
700 error = sockargs(&control, mp->msg_control,
701 mp->msg_controllen, MT_CONTROL);
702 if (error)
703 goto bad;
704#ifdef COMPAT_OLDSOCK
705 if (mp->msg_flags == MSG_COMPAT) {
706 struct cmsghdr *cm;
707
708 M_PREPEND(control, sizeof(*cm), M_TRYWAIT);
709 if (control == 0) {
710 error = ENOBUFS;
711 goto bad;
712 } else {
713 cm = mtod(control, struct cmsghdr *);
714 cm->cmsg_len = control->m_len;
715 cm->cmsg_level = SOL_SOCKET;
716 cm->cmsg_type = SCM_RIGHTS;
717 }
718 }
719#endif
720 } else {
721 control = NULL;
722 }
723
724 error = kern_sendit(td, s, mp, flags, control, UIO_USERSPACE);
725
--- 896 unchanged lines hidden (view full) ---
1622#ifdef COMPAT_OLDSOCK
1623 if (type == MT_SONAME && (u_int)buflen <= 112)
1624 buflen = MLEN; /* unix domain compat. hack */
1625 else
1626#endif
1627 if ((u_int)buflen > MCLBYTES)
1628 return (EINVAL);
1629 }
1630 m = m_get(M_TRYWAIT, type);
1631 if (m == NULL)
1632 return (ENOBUFS);
1633 if ((u_int)buflen > MLEN) {
1634 MCLGET(m, M_TRYWAIT);
1635 if ((m->m_flags & M_EXT) == 0) {
1636 m_free(m);
1637 return (ENOBUFS);
1638 }
1639 }
1640 m->m_len = buflen;
1641 error = copyin(buf, mtod(m, caddr_t), (u_int)buflen);
1642 if (error)
1643 (void) m_free(m);
1644 else {
1645 *mp = m;
1646 if (type == MT_SONAME) {
1647 sa = mtod(m, struct sockaddr *);
--- 1069 unchanged lines hidden ---
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 19 unchanged lines hidden (view full) ---
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/uipc_syscalls.c 176498 2008-02-24 00:07:00Z cperciva $");
37
38#include "opt_sctp.h"
39#include "opt_compat.h"
40#include "opt_ktrace.h"
41#include "opt_mac.h"
42
43#include <sys/param.h>
44#include <sys/systm.h>
--- 655 unchanged lines hidden (view full) ---
700 error = sockargs(&control, mp->msg_control,
701 mp->msg_controllen, MT_CONTROL);
702 if (error)
703 goto bad;
704#ifdef COMPAT_OLDSOCK
705 if (mp->msg_flags == MSG_COMPAT) {
706 struct cmsghdr *cm;
707
708 M_PREPEND(control, sizeof(*cm), M_TRYWAIT);
709 if (control == 0) {
710 error = ENOBUFS;
711 goto bad;
712 } else {
713 cm = mtod(control, struct cmsghdr *);
714 cm->cmsg_len = control->m_len;
715 cm->cmsg_level = SOL_SOCKET;
716 cm->cmsg_type = SCM_RIGHTS;
717 }
718 }
719#endif
720 } else {
721 control = NULL;
722 }
723
724 error = kern_sendit(td, s, mp, flags, control, UIO_USERSPACE);
725
--- 896 unchanged lines hidden (view full) ---
1622#ifdef COMPAT_OLDSOCK
1623 if (type == MT_SONAME && (u_int)buflen <= 112)
1624 buflen = MLEN; /* unix domain compat. hack */
1625 else
1626#endif
1627 if ((u_int)buflen > MCLBYTES)
1628 return (EINVAL);
1629 }
1630 m = m_get(M_TRYWAIT, type);
1631 if (m == NULL)
1632 return (ENOBUFS);
1633 if ((u_int)buflen > MLEN) {
1634 MCLGET(m, M_TRYWAIT);
1635 if ((m->m_flags & M_EXT) == 0) {
1636 m_free(m);
1637 return (ENOBUFS);
1638 }
1639 }
1640 m->m_len = buflen;
1641 error = copyin(buf, mtod(m, caddr_t), (u_int)buflen);
1642 if (error)
1643 (void) m_free(m);
1644 else {
1645 *mp = m;
1646 if (type == MT_SONAME) {
1647 sa = mtod(m, struct sockaddr *);
--- 1069 unchanged lines hidden ---