summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>2011-07-24 15:21:28 +0000
committermillert <>2011-07-24 15:21:28 +0000
commitff139186f8d47a589ecba6abd896915137364e16 (patch)
treeb75df96c2084f081131d6c1808bb02e6a9c4f353 /src
parent6bfe3ab15fc108576b23dc239c3d8e63b0cdc7bb (diff)
downloadopenbsd-ff139186f8d47a589ecba6abd896915137364e16.tar.gz
openbsd-ff139186f8d47a589ecba6abd896915137364e16.tar.bz2
openbsd-ff139186f8d47a589ecba6abd896915137364e16.zip
Sync wcslcpy and wcslcat with strlcpy and strlcat. OK deraadt@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/string/wcslcat.c42
-rw-r--r--src/lib/libc/string/wcslcpy.c34
2 files changed, 26 insertions, 50 deletions
diff --git a/src/lib/libc/string/wcslcat.c b/src/lib/libc/string/wcslcat.c
index bcd52d1f3c..ee8ff3c343 100644
--- a/src/lib/libc/string/wcslcat.c
+++ b/src/lib/libc/string/wcslcat.c
@@ -1,32 +1,20 @@
1/* $OpenBSD: wcslcat.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ 1/* $OpenBSD: wcslcat.c,v 1.4 2011/07/24 15:21:28 millert Exp $ */
2/* $NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */ 2/* $NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
3/* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */
4 3
5/* 4/*
6 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> 5 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
7 * All rights reserved.
8 * 6 *
9 * Redistribution and use in source and binary forms, with or without 7 * Permission to use, copy, modify, and distribute this software for any
10 * modification, are permitted provided that the following conditions 8 * purpose with or without fee is hereby granted, provided that the above
11 * are met: 9 * copyright notice and this permission notice appear in all copies.
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 * 10 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
23 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 18 */
31 19
32#include <sys/types.h> 20#include <sys/types.h>
@@ -35,9 +23,9 @@
35/* 23/*
36 * Appends src to string dst of size siz (unlike wcsncat, siz is the 24 * Appends src to string dst of size siz (unlike wcsncat, siz is the
37 * full size of dst, not space left). At most siz-1 characters 25 * full size of dst, not space left). At most siz-1 characters
38 * will be copied. Always NUL terminates (unless siz == 0). 26 * will be copied. Always NUL terminates (unless siz <= wcslen(dst)).
39 * Returns wcslen(initial dst) + wcslen(src); if retval >= siz, 27 * Returns wcslen(src) + MIN(siz, wcslen(initial dst)).
40 * truncation occurred. 28 * If retval >= siz, truncation occurred.
41 */ 29 */
42size_t 30size_t
43wcslcat(wchar_t *dst, const wchar_t *src, size_t siz) 31wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
@@ -48,7 +36,7 @@ wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
48 size_t dlen; 36 size_t dlen;
49 37
50 /* Find the end of dst and adjust bytes left but don't go past end */ 38 /* Find the end of dst and adjust bytes left but don't go past end */
51 while (*d != '\0' && n-- != 0) 39 while (n-- != 0 && *d != '\0')
52 d++; 40 d++;
53 dlen = d - dst; 41 dlen = d - dst;
54 n = siz - dlen; 42 n = siz - dlen;
diff --git a/src/lib/libc/string/wcslcpy.c b/src/lib/libc/string/wcslcpy.c
index 85f51df35f..f49936a885 100644
--- a/src/lib/libc/string/wcslcpy.c
+++ b/src/lib/libc/string/wcslcpy.c
@@ -1,32 +1,20 @@
1/* $OpenBSD: wcslcpy.c,v 1.4 2006/05/05 15:27:38 millert Exp $ */ 1/* $OpenBSD: wcslcpy.c,v 1.5 2011/07/24 15:21:28 millert Exp $ */
2/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */ 2/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
3/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
4 3
5/* 4/*
6 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> 5 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
7 * All rights reserved.
8 * 6 *
9 * Redistribution and use in source and binary forms, with or without 7 * Permission to use, copy, modify, and distribute this software for any
10 * modification, are permitted provided that the following conditions 8 * purpose with or without fee is hereby granted, provided that the above
11 * are met: 9 * copyright notice and this permission notice appear in all copies.
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 * 10 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
23 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 18 */
31 19
32#include <sys/types.h> 20#include <sys/types.h>