diff options
author | millert <> | 2001-01-12 22:55:23 +0000 |
---|---|---|
committer | millert <> | 2001-01-12 22:55:23 +0000 |
commit | e1a565880c0c92acbfd5246b2a5cd85e75180f61 (patch) | |
tree | ff461d808be0cc0a7c51e709d58d2c43a7379791 | |
parent | ff8efdd42a4336723282416a5045bae7c8b32c8a (diff) | |
download | openbsd-e1a565880c0c92acbfd5246b2a5cd85e75180f61.tar.gz openbsd-e1a565880c0c92acbfd5246b2a5cd85e75180f61.tar.bz2 openbsd-e1a565880c0c92acbfd5246b2a5cd85e75180f61.zip |
Reverse the order of two loop invariant to make 'strlcat(0, "foo", 0)'
not get a SEGV; Richard Kettlewell <rjk@greenend.org.uk>
-rw-r--r-- | src/lib/libc/string/strlcat.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/string/strlcat.c b/src/lib/libc/string/strlcat.c index f7d43bb24b..5a23ef285c 100644 --- a/src/lib/libc/string/strlcat.c +++ b/src/lib/libc/string/strlcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp $ */ | 1 | /* $OpenBSD: strlcat.c,v 1.4 2001/01/12 22:55:23 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
@@ -28,7 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) |
31 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp $"; | 31 | static char *rcsid = "$OpenBSD: strlcat.c,v 1.4 2001/01/12 22:55:23 millert Exp $"; |
32 | #endif /* LIBC_SCCS and not lint */ | 32 | #endif /* LIBC_SCCS and not lint */ |
33 | 33 | ||
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
@@ -52,7 +52,7 @@ size_t strlcat(dst, src, siz) | |||
52 | size_t dlen; | 52 | size_t dlen; |
53 | 53 | ||
54 | /* Find the end of dst and adjust bytes left but don't go past end */ | 54 | /* Find the end of dst and adjust bytes left but don't go past end */ |
55 | while (*d != '\0' && n-- != 0) | 55 | while (n-- != 0 && *d != '\0') |
56 | d++; | 56 | d++; |
57 | dlen = d - dst; | 57 | dlen = d - dst; |
58 | n = siz - dlen; | 58 | n = siz - dlen; |