diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-07-12 02:47:20 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-07-12 02:47:20 +0000 |
commit | 51a43a3f4dbeb4c36b87ca2d29fdc0214639c318 (patch) | |
tree | 54857d96f2ca0275e404c81a0690a15dab35bff7 /usr.sbin | |
parent | 455922fb8cfbc2f6ccd8a6f160a980c746ad0443 (diff) |
rev 1.45
Add a missing memcpy
From brian FreeBSD
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/ppp/mbuf.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/ppp/ppp/mbuf.c b/usr.sbin/ppp/ppp/mbuf.c index ec2b566fe5b..7c00cfa08c7 100644 --- a/usr.sbin/ppp/ppp/mbuf.c +++ b/usr.sbin/ppp/ppp/mbuf.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: mbuf.c,v 1.16 2002/06/15 08:02:00 brian Exp $ + * $OpenBSD: mbuf.c,v 1.17 2005/07/12 02:47:19 brad Exp $ */ #include <sys/types.h> @@ -247,11 +247,13 @@ m_prepend(struct mbuf *bp, const void *ptr, size_t len, size_t extra) if (bp->m_offset >= len) { bp->m_offset -= len; bp->m_len += len; - memcpy(MBUF_CTOP(bp), ptr, len); + if (ptr) + memcpy(MBUF_CTOP(bp), ptr, len); return bp; } len -= bp->m_offset; - memcpy(bp + 1, (const char *)ptr + len, bp->m_offset); + if (ptr) + memcpy(bp + 1, (const char *)ptr + len, bp->m_offset); bp->m_len += bp->m_offset; bp->m_offset = 0; } @@ -424,9 +426,11 @@ m_append(struct mbuf *bp, const void *v, size_t sz) if (m) { while (m->m_next) m = m->m_next; - if (m->m_size - m->m_len > sz) + if (m->m_size - m->m_len >= sz) { + if (v) + memcpy((char *)(m + 1) + m->m_len, v, sz); m->m_len += sz; - else + } else m->m_next = m_prepend(NULL, v, sz, 0); } else bp = m_prepend(NULL, v, sz, 0); |