Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
|
||||
# $NetBSD: Makefile.inc,v 1.76 2012/08/30 12:16:48 drochner Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.79 2013/08/19 10:59:39 joerg Exp $
|
||||
|
||||
# string sources
|
||||
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
|
||||
@@ -19,7 +19,7 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c memchr.c memcmp.c memset.c
|
||||
SRCS+= strcat.c strcmp.c strcpy.c strcspn.c strlen.c
|
||||
SRCS+= strncat.c strncmp.c strncpy.c strpbrk.c strsep.c
|
||||
SRCS+= strspn.c strstr.c swab.c
|
||||
SRCS+= explicit_bzero.c consttime_bcmp.c
|
||||
SRCS+= explicit_memset.c consttime_memequal.c
|
||||
|
||||
SRCS+= memccpy.c memcpy.c memmem.c memmove.c
|
||||
SRCS+= strchr.c strrchr.c
|
||||
@@ -34,12 +34,10 @@ CPPFLAGS.wcscmp.c+= -I${LIBCDIR}/locale
|
||||
CPPFLAGS.wcsncmp.c+= -I${LIBCDIR}/locale
|
||||
CPPFLAGS.wmemcmp.c+= -I${LIBCDIR}/locale
|
||||
|
||||
# namespace protection wrappers
|
||||
SRCS+= _strlcat.c _strlcpy.c _strerror_r.c
|
||||
|
||||
.include "${ARCHDIR}/string/Makefile.inc"
|
||||
|
||||
MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 \
|
||||
MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 consttime_memequal.3 \
|
||||
explicit_memset.3 ffs.3 index.3 \
|
||||
memccpy.3 memchr.3 memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 \
|
||||
popcount.3 \
|
||||
rindex.3 strcasecmp.3 strcat.3 strchr.3 strcmp.3 strcoll.3 \
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/* $NetBSD: _strerror_r.c,v 1.3 2008/04/28 20:23:00 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _strerror_r.c,v 1.3 2008/04/28 20:23:00 martin Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#if defined(__indr_reference)
|
||||
__indr_reference(_strerror_r, strerror_r)
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
int _strerror_r(int, char *, size_t);
|
||||
|
||||
int
|
||||
strerror_r(int num, char *buf, size_t siz)
|
||||
{
|
||||
|
||||
return _strerror_r(num, buf, siz);
|
||||
}
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/* $NetBSD: _strlcat.c,v 1.5 2009/10/21 01:07:45 snj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _strlcat.c,v 1.5 2009/10/21 01:07:45 snj Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#if defined(__indr_reference)
|
||||
__indr_reference(_strlcat, strlcat)
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
size_t _strlcat(char *, const char *, size_t);
|
||||
|
||||
size_t
|
||||
strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
|
||||
return _strlcat(dst, src, siz);
|
||||
}
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/* $NetBSD: _strlcpy.c,v 1.5 2009/10/21 01:07:45 snj Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: _strlcpy.c,v 1.5 2009/10/21 01:07:45 snj Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#if defined(__indr_reference)
|
||||
__indr_reference(_strlcpy, strlcpy)
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
size_t _strlcpy(char *, const char *, size_t);
|
||||
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
|
||||
return _strlcpy(dst, src, siz);
|
||||
}
|
||||
#endif
|
||||
88
lib/libc/string/consttime_memequal.3
Normal file
88
lib/libc/string/consttime_memequal.3
Normal file
@@ -0,0 +1,88 @@
|
||||
.\" $NetBSD: consttime_memequal.3,v 1.2 2013/08/28 15:24:41 riastradh Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This documentation is derived from text contributed to The NetBSD
|
||||
.\" Foundation by Taylor R. Campbell.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd August 28, 2013
|
||||
.Dt CONSTTIME_MEMEQUAL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm consttime_memequal
|
||||
.Nd compare byte strings for equality without timing leaks
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In string.h
|
||||
.Ft int
|
||||
.Fn consttime_memequal "void *b1" "void *b2" "size_t len"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn consttime_memequal
|
||||
function compares
|
||||
.Fa len
|
||||
bytes of memory at
|
||||
.Fa b1
|
||||
and
|
||||
.Fa b2
|
||||
for equality, returning zero if they are distinct and nonzero if they
|
||||
are identical.
|
||||
.Pp
|
||||
The time taken by
|
||||
.Fn consttime_memequal
|
||||
depends on
|
||||
.Fa len ,
|
||||
but not on the data at
|
||||
.Fa b1
|
||||
or
|
||||
.Fa b2 .
|
||||
Thus,
|
||||
.Fn consttime_memequal
|
||||
is appropriate for comparing cryptographic secrets, hashes, message
|
||||
authentication codes, etc., without leaking information about them
|
||||
through a timing side channel.
|
||||
In crypto literature,
|
||||
.Fn consttime_memequal
|
||||
is said to take
|
||||
.Sq constant time ,
|
||||
meaning time that does not vary depending on the data it processes.
|
||||
.Pp
|
||||
Note that unlike
|
||||
.Xr memcmp 3 ,
|
||||
.Fn consttime_memequal
|
||||
does not return a lexicographic ordering on the data at
|
||||
.Fa b1
|
||||
and
|
||||
.Fa b2 ;
|
||||
it tells only whether they are equal.
|
||||
.Sh SEE ALSO
|
||||
.Xr explicit_memset 3 ,
|
||||
.Xr memcmp 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn consttime_memequal
|
||||
function appeared in
|
||||
.Nx 7.0 .
|
||||
82
lib/libc/string/explicit_memset.3
Normal file
82
lib/libc/string/explicit_memset.3
Normal file
@@ -0,0 +1,82 @@
|
||||
.\" $NetBSD: explicit_memset.3,v 1.2 2013/08/28 15:46:23 riastradh Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This documentation is derived from text contributed to The NetBSD
|
||||
.\" Foundation by Taylor R. Campbell.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd August 28, 2013
|
||||
.Dt EXPLICIT_MEMSET 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm explicit_memset
|
||||
.Nd guarantee writing a byte to a byte string
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In string.h
|
||||
.Ft void *
|
||||
.Fn explicit_memset "void *b" "int c" "size_t len"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn explicit_memset
|
||||
function writes
|
||||
.Fa len
|
||||
bytes of value
|
||||
.Fa c
|
||||
(converted to an unsigned char) to the string
|
||||
.Fa b .
|
||||
It is guaranteed not to be optimized away by the compiler even if
|
||||
.Fa b
|
||||
is no longer used and is about to be freed or go out of scope.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn explicit_memset
|
||||
function returns the original value of
|
||||
.Fa b .
|
||||
.Sh EXAMPLES
|
||||
Create a buffer on the stack for a secret key, use it, and then zero it
|
||||
in memory before throwing it away.
|
||||
.Bd -literal -offset indent
|
||||
void
|
||||
f(void)
|
||||
{
|
||||
uint8_t key[32];
|
||||
|
||||
crypto_random(key, sizeof(key));
|
||||
do_crypto_stuff(key, sizeof(key));
|
||||
\&...
|
||||
|
||||
explicit_memset(key, 0, sizeof(key));
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr consttime_memequal 3 ,
|
||||
.Xr memset 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn explicit_memset
|
||||
function appeared in
|
||||
.Nx 7.0 .
|
||||
@@ -30,9 +30,9 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)memcmp.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $NetBSD: memcmp.3,v 1.9 2003/08/07 16:43:48 agc Exp $
|
||||
.\" $NetBSD: memcmp.3,v 1.11 2013/06/24 04:21:20 riastradh Exp $
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd June 23, 2013
|
||||
.Dt MEMCMP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -67,8 +67,18 @@ is greater than
|
||||
.Sq Li \&\e0 ,
|
||||
for example).
|
||||
Zero-length strings are always identical.
|
||||
.Pp
|
||||
Do not use
|
||||
.Fn memcmp
|
||||
to compare cryptographic secrets, because the time it takes varies
|
||||
depending on how many bytes are the same, and thus leaks information
|
||||
about the two strings by a timing side channel.
|
||||
To compare secrets, hashes, message authentication codes, etc., use
|
||||
.Xr consttime_memequal 3
|
||||
instead.
|
||||
.Sh SEE ALSO
|
||||
.Xr bcmp 3 ,
|
||||
.Xr consttime_memequal 3 ,
|
||||
.Xr strcasecmp 3 ,
|
||||
.Xr strcmp 3 ,
|
||||
.Xr strcoll 3 ,
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)memset.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $NetBSD: memset.3,v 1.9 2003/08/07 16:43:49 agc Exp $
|
||||
.\" $NetBSD: memset.3,v 1.12 2013/06/24 07:56:49 wiz Exp $
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd June 23, 2013
|
||||
.Dt MEMSET 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -60,8 +60,17 @@ The
|
||||
function
|
||||
returns the original value of
|
||||
.Fa b .
|
||||
.Pp
|
||||
Note that the compiler may optimize away a call to
|
||||
.Fn memset
|
||||
if it can prove that the string will not be used by the program again,
|
||||
for example if it is allocated on the stack and about to out of scope.
|
||||
If you want to guarantee that zeros are written to memory, for example
|
||||
to sanitize a buffer holding a cryptographic secret, use
|
||||
.Xr explicit_memset 3 .
|
||||
.Sh SEE ALSO
|
||||
.Xr bzero 3 ,
|
||||
.Xr explicit_memset 3 ,
|
||||
.Xr swab 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: stpcpy.c,v 1.1 2009/05/01 17:27:01 perry Exp $ */
|
||||
/* $NetBSD: stpcpy.c,v 1.2 2013/11/06 21:05:27 tron Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999
|
||||
@@ -36,13 +36,17 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: stpcpy.c,v 1.1 2009/05/01 17:27:01 perry Exp $");
|
||||
__RCSID("$NetBSD: stpcpy.c,v 1.2 2013/11/06 21:05:27 tron Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
/* FreeBSD: src/lib/libc/string/stpcpy.c,v 1.2 2009/02/28 06:05:37 das Exp */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _FORTIFY_SOURCE
|
||||
#undef stpcpy
|
||||
#endif
|
||||
|
||||
char *
|
||||
stpcpy(char * __restrict to, const char * __restrict from)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: stpncpy.c,v 1.1 2009/05/01 17:27:01 perry Exp $ */
|
||||
/* $NetBSD: stpncpy.c,v 1.2 2013/11/06 21:05:27 tron Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 David Schultz <das@FreeBSD.org>
|
||||
@@ -28,12 +28,16 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: stpncpy.c,v 1.1 2009/05/01 17:27:01 perry Exp $");
|
||||
__RCSID("$NetBSD: stpncpy.c,v 1.2 2013/11/06 21:05:27 tron Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
/* FreeBSD: src/lib/libc/string/stpncpy.c,v 1.1 2009/02/28 06:00:58 das Exp */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _FORTIFY_SOURCE
|
||||
#undef stpncpy
|
||||
#endif
|
||||
|
||||
char *
|
||||
stpncpy(char * __restrict dst, const char * __restrict src, size_t n)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $ */
|
||||
/* $NetBSD: strcoll.c,v 1.12 2013/05/17 12:55:57 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,12 +37,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)strcoll.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: strcoll.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
|
||||
__RCSID("$NetBSD: strcoll.c,v 1.12 2013/05/17 12:55:57 joerg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include "setlocale_local.h"
|
||||
|
||||
__weak_alias(strcoll_l, _strcoll_l)
|
||||
|
||||
/*
|
||||
* Compare strings according to LC_COLLATE category of current locale.
|
||||
@@ -51,9 +57,16 @@ int
|
||||
strcoll(const char *s1, const char *s2)
|
||||
{
|
||||
|
||||
return strcoll_l(s1, s2, _current_locale());
|
||||
}
|
||||
|
||||
int
|
||||
strcoll_l(const char *s1, const char *s2, locale_t loc)
|
||||
{
|
||||
_DIAGASSERT(s1 != NULL);
|
||||
_DIAGASSERT(s2 != NULL);
|
||||
|
||||
/* LC_COLLATE is unimplemented, hence always "C" */
|
||||
/* LINTED */ (void)loc;
|
||||
return (strcmp(s1, s2));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strerror.c,v 1.14 2006/01/26 11:13:42 kleink Exp $ */
|
||||
/* $NetBSD: strerror.c,v 1.16 2013/09/02 07:59:32 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Regents of the University of California.
|
||||
@@ -30,30 +30,66 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char *sccsid = "@(#)strerror.c 5.6 (Berkeley) 5/4/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: strerror.c,v 1.14 2006/01/26 11:13:42 kleink Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
__RCSID("$NetBSD: strerror.c,v 1.16 2013/09/02 07:59:32 joerg Exp $");
|
||||
|
||||
#define __SETLOCALE_SOURCE__
|
||||
|
||||
#include "namespace.h"
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include "extern.h"
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Since perror() is not allowed to change the contents of strerror()'s
|
||||
* static buffer, both functions supply their own buffers to strerror_r()
|
||||
*/
|
||||
#include "extern.h"
|
||||
#ifdef _REENTRANT
|
||||
#include "reentrant.h"
|
||||
#endif
|
||||
#include "setlocale_local.h"
|
||||
|
||||
__weak_alias(strerror_l, _strerror_l)
|
||||
|
||||
__aconst char *
|
||||
strerror(int num)
|
||||
{
|
||||
|
||||
return strerror_l(num, _current_locale());
|
||||
}
|
||||
|
||||
#ifdef _REENTRANT
|
||||
static thread_key_t strerror_key;
|
||||
static once_t strerror_once = ONCE_INITIALIZER;
|
||||
|
||||
static void
|
||||
strerror_setup(void)
|
||||
{
|
||||
|
||||
thr_keycreate(&strerror_key, free);
|
||||
}
|
||||
#endif
|
||||
|
||||
__aconst char *
|
||||
strerror_l(int num, locale_t loc)
|
||||
{
|
||||
int error;
|
||||
#ifdef _REENTRANT
|
||||
char *buf;
|
||||
|
||||
thr_once(&strerror_once, strerror_setup);
|
||||
buf = thr_getspecific(strerror_key);
|
||||
if (buf == NULL) {
|
||||
buf = malloc(NL_TEXTMAX);
|
||||
if (buf == NULL) {
|
||||
static char fallback_buf[NL_TEXTMAX];
|
||||
buf = fallback_buf;
|
||||
}
|
||||
thr_setspecific(strerror_key, buf);
|
||||
}
|
||||
#else
|
||||
static char buf[NL_TEXTMAX];
|
||||
int error = strerror_r(num, buf, sizeof(buf));
|
||||
#endif
|
||||
|
||||
error = _strerror_lr(num, buf, NL_TEXTMAX, loc);
|
||||
if (error)
|
||||
errno = error;
|
||||
return buf;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strerror_r.c,v 1.2 2005/07/30 15:21:21 christos Exp $ */
|
||||
/* $NetBSD: strerror_r.c,v 1.3 2013/08/19 13:03:12 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Regents of the University of California.
|
||||
@@ -30,38 +30,27 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char *sccsid = "@(#)strerror.c 5.6 (Berkeley) 5/4/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: strerror_r.c,v 1.2 2005/07/30 15:21:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
__RCSID("$NetBSD: strerror_r.c,v 1.3 2013/08/19 13:03:12 joerg Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
#ifdef NLS
|
||||
#include <limits.h>
|
||||
#include <nl_types.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef NLS
|
||||
#include <limits.h>
|
||||
#include <nl_types.h>
|
||||
#define __SETLOCALE_SOURCE__
|
||||
#include <locale.h>
|
||||
#include "setlocale_local.h"
|
||||
#endif
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef __weak_alias
|
||||
__weak_alias(strerror_r, _strerror_r)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
#ifdef _LIBC
|
||||
_strerror_r(int num, char *buf, size_t buflen)
|
||||
#else
|
||||
strerror_r(int num, char *buf, size_t buflen)
|
||||
#endif
|
||||
_strerror_lr(int num, char *buf, size_t buflen, locale_t loc)
|
||||
{
|
||||
#define UPREFIX "Unknown error: %u"
|
||||
unsigned int errnum = num;
|
||||
@@ -70,7 +59,7 @@ strerror_r(int num, char *buf, size_t buflen)
|
||||
#ifdef NLS
|
||||
int saved_errno = errno;
|
||||
nl_catd catd;
|
||||
catd = catopen("libc", NL_CAT_LOCALE);
|
||||
catd = catopen_l("libc", NL_CAT_LOCALE, loc);
|
||||
#endif
|
||||
_DIAGASSERT(buf != NULL);
|
||||
|
||||
@@ -83,7 +72,7 @@ strerror_r(int num, char *buf, size_t buflen)
|
||||
#endif
|
||||
} else {
|
||||
#ifdef NLS
|
||||
slen = snprintf(buf, buflen,
|
||||
slen = snprintf_l(buf, buflen, loc,
|
||||
catgets(catd, 1, 0xffff, UPREFIX), errnum);
|
||||
#else
|
||||
slen = snprintf(buf, buflen, UPREFIX, errnum);
|
||||
@@ -101,3 +90,13 @@ strerror_r(int num, char *buf, size_t buflen)
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
strerror_r(int num, char *buf, size_t buflen)
|
||||
{
|
||||
#ifdef NLS
|
||||
return _strerror_lr(num, buf, buflen, _current_locale());
|
||||
#else
|
||||
return _strerror_lr(num, buf, buflen, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: strxfrm.c,v 1.12 2012/06/25 22:32:46 abs Exp $ */
|
||||
/* $NetBSD: strxfrm.c,v 1.14 2013/05/17 12:55:57 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -37,12 +37,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)strxfrm.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: strxfrm.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
|
||||
__RCSID("$NetBSD: strxfrm.c,v 1.14 2013/05/17 12:55:57 joerg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
#include "setlocale_local.h"
|
||||
|
||||
__weak_alias(strxfrm_l, _strxfrm_l)
|
||||
|
||||
/*
|
||||
* Transform src, storing the result in dst, such that
|
||||
@@ -50,12 +56,15 @@ __RCSID("$NetBSD: strxfrm.c,v 1.12 2012/06/25 22:32:46 abs Exp $");
|
||||
* on the original untransformed strings would return.
|
||||
*/
|
||||
size_t
|
||||
strxfrm(char *dst, const char *src, size_t n)
|
||||
strxfrm_l(char *dst, const char *src, size_t n, locale_t loc)
|
||||
{
|
||||
size_t srclen, copysize;
|
||||
|
||||
_DIAGASSERT(src != NULL);
|
||||
|
||||
/* XXX: LC_COLLATE should be implemented. */
|
||||
/* LINTED */(void)loc;
|
||||
|
||||
/*
|
||||
* Since locales are unimplemented, this is just a copy.
|
||||
*/
|
||||
@@ -68,3 +77,9 @@ strxfrm(char *dst, const char *src, size_t n)
|
||||
}
|
||||
return (srclen);
|
||||
}
|
||||
|
||||
size_t
|
||||
strxfrm(char *dst, const char *src, size_t n)
|
||||
{
|
||||
return strxfrm_l(dst, src, n, _current_locale());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: wcscasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $ */
|
||||
/* $NetBSD: wcscasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Aleksey Cheusov
|
||||
@@ -13,18 +13,21 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: wcscasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $");
|
||||
__RCSID("$NetBSD: wcscasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <locale.h>
|
||||
#include "setlocale_local.h"
|
||||
|
||||
__weak_alias(wcscasecmp,_wcscasecmp)
|
||||
__weak_alias(wcscasecmp_l,_wcscasecmp_l)
|
||||
|
||||
int
|
||||
wcscasecmp(const wchar_t *s1, const wchar_t *s2)
|
||||
wcscasecmp_l(const wchar_t *s1, const wchar_t *s2, locale_t loc)
|
||||
{
|
||||
int lc1 = 0;
|
||||
int lc2 = 0;
|
||||
@@ -34,8 +37,8 @@ wcscasecmp(const wchar_t *s1, const wchar_t *s2)
|
||||
_DIAGASSERT(s2);
|
||||
|
||||
for (;;) {
|
||||
lc1 = towlower(*s1);
|
||||
lc2 = towlower(*s2);
|
||||
lc1 = towlower_l(*s1, loc);
|
||||
lc2 = towlower_l(*s2, loc);
|
||||
|
||||
diff = lc1 - lc2;
|
||||
if (diff)
|
||||
@@ -48,3 +51,9 @@ wcscasecmp(const wchar_t *s1, const wchar_t *s2)
|
||||
++s2;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
wcscasecmp(const wchar_t *s1, const wchar_t *s2)
|
||||
{
|
||||
return wcscasecmp_l(s1, s2, _current_locale());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $
|
||||
.\" $NetBSD: wcsdup.3,v 1.4 2012/12/28 13:53:12 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -34,7 +34,7 @@
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm wcsdup
|
||||
.Nd save a copy of a string
|
||||
.Nd save a copy of a wide string
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: wcsncasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $ */
|
||||
/* $NetBSD: wcsncasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006 Aleksey Cheusov
|
||||
@@ -13,18 +13,21 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: wcsncasecmp.c,v 1.2 2006/08/26 22:45:52 christos Exp $");
|
||||
__RCSID("$NetBSD: wcsncasecmp.c,v 1.4 2013/05/17 12:55:57 joerg Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <locale.h>
|
||||
#include "setlocale_local.h"
|
||||
|
||||
__weak_alias(wcsncasecmp,_wcsncasecmp)
|
||||
__weak_alias(wcsncasecmp_l,_wcsncasecmp_l)
|
||||
|
||||
int
|
||||
wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||
wcsncasecmp_l(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t loc)
|
||||
{
|
||||
int lc1 = 0;
|
||||
int lc2 = 0;
|
||||
@@ -34,8 +37,8 @@ wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||
_DIAGASSERT(s2);
|
||||
|
||||
while (n--) {
|
||||
lc1 = towlower (*s1);
|
||||
lc2 = towlower (*s2);
|
||||
lc1 = towlower_l(*s1, loc);
|
||||
lc2 = towlower_l(*s2, loc);
|
||||
|
||||
diff = lc1 - lc2;
|
||||
if (diff)
|
||||
@@ -50,3 +53,9 @@ wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||
{
|
||||
return wcsncasecmp_l(s1, s2, n, _current_locale());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user