Re: Unanticipated test error

From: Alex Riesen <raa.lkml@gmail.com>
Date: 2006-07-22 00:54:57
On 7/21/06, Peter Eriksen <s022018@student.dtu.dk> wrote:
> ...
> > Well, there are differences. Correct translation from memcpy
> > to strlcpy (aside the fact with \0 inside the string) would be
> > something like:
> >
> >  strlcpy(to, from, len + 1);
> >
> > assuming your example with memcpy. strlcpy expects size of
> > storage, and will never write more bytes that it was allowed to.
> > That'll cut off last character of the source string, unless it is
> > \0-terminated before the size of storage.
>
> I see it now.  What I did was wrong.  Appending " + 1" to every
> one of my calls makes the patch survive "make test".  However,
> since strlcpy() calls strlen(from), it would have to be checked,
> that 'from' is always NUL terminated.  The benefits of this patch
> seem to shrink.

Probably, but you still have room to balance benefits.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Sat Jul 22 00:55:50 2006

This archive was generated by hypermail 2.1.8 : 2006-07-22 00:56:19 EST