Fix strlcpy in kernel, add strlcat.
authorDan Cross <crossd@gmail.com>
Thu, 15 Oct 2015 20:51:55 +0000 (16:51 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Oct 2015 16:20:48 +0000 (12:20 -0400)
commit80c0f85995de9bdfabc67dd49f0763a67bc76fd0
tree7f06ca8d235db4fdeb61c973bedd6f2521b472fc
parent02c50b1a87ddc9bc46ad4ecfbd23b4bccc2913f3
Fix strlcpy in kernel, add strlcat.

The return value of strlcpy was incorrect: it was returning
the amount it had copied, but the return value is supposed to
be the size of the input string.

I also added strlcat (with a prodigious comment, as the code
is subtle) for parity.

Nothing was checking the return value of strlcpy as far as I
could see, and while it's not specified by e.g. ANSI/ISO, it
still makes sense for us to follow the specification of other
implementations.

Tested: Rebuilt the kernel and ran Akaros.

References:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/strlcat.3?query=strlcpy&sec=3
http://www.sudo.ws/todd/papers/strlcpy.html

Signed-off-by: Dan Cross <crossd@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/string.h
kern/src/string.c