pull in openbsd strlcat.c 1.3 -> 1.4.

Reverse the order of two loop invariant to make 'strlcat(0, "foo", 0)'
not get a SEGV; Richard Kettlewell <rjk@greenend.org.uk>
This commit is contained in:
itojun 2001-01-13 04:19:54 +00:00
parent 27980172f6
commit 0e83f5f0d1
2 changed files with 7 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/* $NetBSD: strlcat.c,v 1.7 2001/01/03 14:33:02 lukem Exp $ */
/* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */
/* $NetBSD: strlcat.c,v 1.8 2001/01/13 04:19:54 itojun Exp $ */
/* $OpenBSD: strlcat.c,v 1.4 2001/01/12 22:55:23 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: strlcat.c,v 1.7 2001/01/03 14:33:02 lukem Exp $");
__RCSID("$NetBSD: strlcat.c,v 1.8 2001/01/13 04:19:54 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -59,7 +59,7 @@ strlcat(dst, src, siz)
_DIAGASSERT(src != NULL);
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;

View File

@ -1,5 +1,5 @@
/* $NetBSD: strlcpy.c,v 1.6 2001/01/03 14:33:02 lukem Exp $ */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/* $NetBSD: strlcpy.c,v 1.7 2001/01/13 04:19:54 itojun Exp $ */
/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: strlcpy.c,v 1.6 2001/01/03 14:33:02 lukem Exp $");
__RCSID("$NetBSD: strlcpy.c,v 1.7 2001/01/13 04:19:54 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>