summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c7
-rw-r--r--sys/kern/uipc_socket.c10
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 4161ac8..e9ff7b0 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1643,8 +1643,11 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags)
if (align >= MHLEN)
return (NULL);
- /* Give us all or nothing. */
- m = m_getm2(NULL, total + align, how, MT_DATA, flags);
+ /*
+ * Give us the full allocation or nothing.
+ * If len is zero return the smallest empty mbuf.
+ */
+ m = m_getm2(NULL, max(total + align, 1), how, MT_DATA, flags);
if (m == NULL)
return (NULL);
m->m_data += align;
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index a87d04f..d1ce038 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1055,6 +1055,11 @@ sosend_dgram(so, addr, uio, top, control, flags, td)
if (error)
goto out;
#else
+ /*
+ * Copy the data from userland into a mbuf chain.
+ * If no data is to be copied in, a single empty mbuf
+ * is returned.
+ */
top = m_uiotombuf(uio, M_WAITOK, space, max_hdr,
(M_PKTHDR | ((flags & MSG_EOR) ? M_EOR : 0)));
if (top == NULL) {
@@ -1230,6 +1235,11 @@ restart:
goto release;
}
#else
+ /*
+ * Copy the data from userland into a mbuf
+ * chain. If no data is to be copied in,
+ * a single empty mbuf is returned.
+ */
top = m_uiotombuf(uio, M_WAITOK, space,
(atomic ? max_hdr : 0),
(atomic ? M_PKTHDR : 0) |
OpenPOWER on IntegriCloud