From d40f76673727cfca2faa0ce6c2573ec75e026afc Mon Sep 17 00:00:00 2001 From: henning <> Date: Wed, 9 Mar 2005 14:07:00 +0000 Subject: [PATCH] when, after processing all complete imsgs we found in the buffer, there are some bytes left (less than an imsg header, or less than the imsg header len field says) we copy it to the very beginning of the buffer. use memmove instead of memcpy since it is not guaranteed that there's no overlap. while memcpy on OpenBSD is safe, it might not elsewhere, and we want our code to be correct anyways. funny enough theo and I talked at length about that last week in dublin, and I said I believe I had no memcpys with the chance of overlap in ntpd/bgpd - well, here is one, and Alexander von Gernler pointed me to it. --- src/usr.sbin/ntpd/imsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr.sbin/ntpd/imsg.c b/src/usr.sbin/ntpd/imsg.c index 3b286d48..9c62dc0d 100644 --- a/src/usr.sbin/ntpd/imsg.c +++ b/src/usr.sbin/ntpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.8 2005/03/06 18:36:52 henning Exp $ */ +/* $OpenBSD: imsg.c,v 1.9 2005/03/09 14:07:00 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -83,7 +83,7 @@ imsg_get(struct imsgbuf *ibuf, struct imsg *imsg) if (imsg->hdr.len < av) { left = av - imsg->hdr.len; - memcpy(&ibuf->r.buf, ibuf->r.buf + imsg->hdr.len, left); + memmove(&ibuf->r.buf, ibuf->r.buf + imsg->hdr.len, left); ibuf->r.wpos = left; } else ibuf->r.wpos = 0;