diff options
Diffstat (limited to 'openbsd-compat/strlcpy.c')
-rw-r--r-- | openbsd-compat/strlcpy.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/openbsd-compat/strlcpy.c b/openbsd-compat/strlcpy.c index c8fe29987..2f87eca44 100644 --- a/openbsd-compat/strlcpy.c +++ b/openbsd-compat/strlcpy.c | |||
@@ -1,30 +1,42 @@ | |||
1 | /* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ | 1 | /* $OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt 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> |
5 | * All rights reserved. | ||
5 | * | 6 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | 7 | * Redistribution and use in source and binary forms, with or without |
7 | * purpose with or without fee is hereby granted, provided that the above | 8 | * modification, are permitted provided that the following conditions |
8 | * copyright notice and this permission notice appear in all copies. | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of the author may not be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
9 | * | 17 | * |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 21 | * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 24 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
26 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
17 | */ | 28 | */ |
18 | 29 | ||
19 | #include "includes.h" | 30 | #include "includes.h" |
20 | #ifndef HAVE_STRLCPY | 31 | #ifndef HAVE_STRLCPY |
21 | 32 | ||
22 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
23 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $"; | 34 | static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp $"; |
24 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
25 | 36 | ||
26 | #include <sys/types.h> | 37 | #include <sys/types.h> |
27 | #include <string.h> | 38 | #include <string.h> |
39 | #include "strlcpy.h" | ||
28 | 40 | ||
29 | /* | 41 | /* |
30 | * Copy src to string dst of size siz. At most siz-1 characters | 42 | * Copy src to string dst of size siz. At most siz-1 characters |
@@ -32,7 +44,10 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp | |||
32 | * Returns strlen(src); if retval >= siz, truncation occurred. | 44 | * Returns strlen(src); if retval >= siz, truncation occurred. |
33 | */ | 45 | */ |
34 | size_t | 46 | size_t |
35 | strlcpy(char *dst, const char *src, size_t siz) | 47 | strlcpy(dst, src, siz) |
48 | char *dst; | ||
49 | const char *src; | ||
50 | size_t siz; | ||
36 | { | 51 | { |
37 | register char *d = dst; | 52 | register char *d = dst; |
38 | register const char *s = src; | 53 | register const char *s = src; |