A Few Additional Words About CVE-2014-0591

Evan Hunt each at isc.org
Mon Jan 13 23:34:06 UTC 2014


On Mon, Jan 13, 2014 at 04:44:22PM -0600, Lawrence K. Chen, P.Eng. wrote:
> Hmmm, from what I vaguely recall from my software engineering days, was
> that memcpy() didn't ever handle overlapped memory buffers and that you
> should consider memmove() in such cases.

Yes, that's correct, and in fact we're replacing all uses of memcpy()
with memmove() in upcoming releases.

Oddly enough, I benchmarked both routines in the newest version of
glibc on amd64, and found that memmove() consistently runs about 35%
faster than memcpy().  So it's both safer *and* faster.

On most platforms, memcpy() does work safely with overlapping buffers,
but the POSIX standard doesn't require it to do so, and you're not
supposed to rely on it.  We had a coding error that caused such a
copy, but there were no bad effects, so we missed it --  until glibc
changed their memcpy() and revealed our mistake.

(And we would've gotten away with it, too, if it wasn't for those
meddling kids.)

-- 
Evan Hunt -- each at isc.org
Internet Systems Consortium, Inc.


More information about the bind-users mailing list