✘Prevent potential buffer overruns in the mode 6 code.
Eric S. Raymond
esr at thyrsus.com
Tue Sep 5 01:53:28 UTC 2017
Matthew Selsky via devel <devel at ntpsec.org>:
> On Mon, Mar 13, 2017 at 12:11:47PM -0700, Gary E. Miller wrote:
> > Yo Ertic!
> >
> >
> > cp = buffer;
> > cq = tag;
> > - while (*cq != '\0')
> > + while (*cq != '\0' && cp < buffer + sizeof(buffer) - 1)
> > *cp++ = *cq++;
> >
> >
> > Why not just use strlcpy? NTPsec has its own copy if the OS does
> > not provide it. This sort of bit-picky C code is where problems lurk.
>
> Hey Eric,
>
> Was there an off-list answer to this? Can we switch to strlcpy() for the cases where we're copying null-terminated strings?
Sorry, was off for the weekend and missed this.
I agree with "This sort of bit-picky C code is where problems lurk" and I'd
have absolutely no objection to moving to strlcpy in cases like this.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
Please consider contributing to my Patreon page at https://www.patreon.com/esr
so I can keep the invisible wheels of the Internet turning. Give generously -
the civilization you save might be your own.
More information about the devel
mailing list