Browse Source

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 <grunk@pestilenz.org> pointed
me to it.
OPENBSD_3_7
henning 20 years ago
parent
commit
d40f766737
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/usr.sbin/ntpd/imsg.c

+ 2
- 2
src/usr.sbin/ntpd/imsg.c View File

@ -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 <henning@openbsd.org>
@ -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;


Loading…
Cancel
Save