summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/mbuf.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-01-03 20:09:23 +0000
committerbrian <brian@FreeBSD.org>2000-01-03 20:09:23 +0000
commit928cb58803557123834cbc1a360cc2c76de8fe3b (patch)
tree66b14e59b870987bd69cf215347f6b9753f2f5c4 /usr.sbin/ppp/mbuf.c
parent4e3562decbae6b85c02a780004c559dfc46b8077 (diff)
downloadFreeBSD-src-928cb58803557123834cbc1a360cc2c76de8fe3b.zip
FreeBSD-src-928cb58803557123834cbc1a360cc2c76de8fe3b.tar.gz
Ensure that there's a bit of extra space in our buffer when it's
passed to libalias. If there's not enough space, things like ftp PORT commands start failing.... Reported by: Gianmarco Giovannelli <gmarco@giovannelli.it>
Diffstat (limited to 'usr.sbin/ppp/mbuf.c')
-rw-r--r--usr.sbin/ppp/mbuf.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c
index 2d1df62..5bd58dc 100644
--- a/usr.sbin/ppp/mbuf.c
+++ b/usr.sbin/ppp/mbuf.c
@@ -234,7 +234,8 @@ m_prepend(struct mbuf *bp, const void *ptr, size_t len, size_t extra)
head = m_get(len + extra, bp ? bp->m_type : MB_UNKNOWN);
head->m_offset = extra;
head->m_len -= extra;
- memcpy(MBUF_CTOP(head), ptr, len);
+ if (ptr)
+ memcpy(MBUF_CTOP(head), ptr, len);
head->m_next = bp;
return head;
@@ -398,3 +399,19 @@ m_settype(struct mbuf *bp, int type)
MemMap[type].octets += bp->m_size;
}
}
+
+struct mbuf *
+m_append(struct mbuf *m, const void *v, size_t sz)
+{
+ if (m) {
+ while (m->m_next)
+ m = m->m_next;
+ if (m->m_size - m->m_len > sz)
+ m->m_len += sz;
+ else
+ m->m_next = m_prepend(NULL, v, sz, 0);
+ } else
+ m = m_prepend(NULL, v, sz, 0);
+
+ return m;
+}
OpenPOWER on IntegriCloud