[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-tech
Subject: Re: Patch for bogus pointer arithmetic in adw(4)
From: Theo de Raadt <deraadt () cvs ! openbsd ! org>
Date: 2010-06-23 14:53:19
Message-ID: 201006231453.o5NErJE3005429 () cvs ! openbsd ! org
[Download RAW message or body]
> On Tue, Jun 22, 2010 at 03:40:44PM -0300, Hudson Flavio V Mateus wrote:
> > >> Is there any reson you use bcopy() not memcpy()?
> > >> If not considder using memcpy() please. :)
> >
> > > We couldn't care what you believe, unless you have diffs of your own
> > > to submit.
> >
> > I think the guy there asked if there is any difference, it was just that. I
> > also don't know bcopy() and would like to know just out of curiosity (I'm
> > really don't know, isn't not an irony): there's some difference between
> > bcopy() and memcpy()?
>
> In the hope of bringing *some* merit to this thread: there is, indeed,
> an important difference between these functions: bcopy() is defined to
> work properly for overlapping buffers (e.g. "bcopy(buf, buf + 1,
> sizeof(buf) - 1)" will work as expected).
Totally true.
bcopy is not memcpy with the arguemnts copied.
bcopy is memmove with the arguments copied.
> memcpy() does have this
> property on OpenBSD, but portable code should obviously not rely on
> that. Of course, kernel code is not (meant to be) portable.
There is this cynical note:
BUGS
In this implementation memcpy() is implemented using bcopy(3), and
therefore the buffers may overlap. On other systems, copying overlapping
buffers may produce surprises. A simpler solution is to not use
memcpy().
A standards commitee chose to keep memcpy, and make people use an interface
which is so dangerous.
Those standards people have no idea what a safe interface is. They have two
jobs:
a) pick the worst interface, when paid
b) make changes that break things
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic