Off by one?
Posted May 30, 2003 4:40 UTC (Fri) by
ncm (subscriber, #165)
In reply to:
Off by one? by raph
Parent article:
strlcpy()
I agree, Neil's is buggy. Walk through it with size == 1.
It clobbers one beyond the end of the input array.
I wonder if we should bother about what to do if size == 0.
Mine crashes spectacularly, which is a Good Thing.
Getting within 15% of memcpy is pretty damn good, in my estimation.
Of course I didn't read Linus's version, or OpenBSD's; that would be
cheating, and I would be tainted besides. Of course now that I have
been told, via cleanroom methods, I can adjust mine to be equally
fast, and maybe (one can hope) actually identical to both Linus's and
OpenBSD's.
(
Log in to post comments)