tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Theo chiming in on strlcpy
On Sun, Dec 22, 2013 at 09:05:44PM +0100, Holger Weiss wrote:
> >
> > Okay, show me your code.
>
> static char *
> concat(const char *s1, const char *s2)
> {
> size_t l1 = strlen(s1);
> size_t l2 = strlen(s2);
> size_t size;
>
> if (((size = l1 + l2) <= l1 && l2 != 0) || ++size == 0)
> abort(); /* Handle `size_t' overflow. */
> return strcat(strcpy(xmalloc(size), s1), s2);
> }
And now another thread changes the data between the strlen()
and strcpy/strcat() calls...
David
--
David Laight: david%l8s.co.uk@localhost
Home |
Main Index |
Thread Index |
Old Index