From 3fd98197832d76ffc7a77c635b9cd424b6aa4341 Mon Sep 17 00:00:00 2001 From: theraven Date: Fri, 6 Jul 2012 20:16:22 +0000 Subject: Restore the __collate_load_error global that was accidentally removed in the xlocale refactoring. MFC after: 1 week --- lib/libc/locale/collate.c | 10 ++++++---- lib/libc/locale/setrunelocale.c | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index 448e605..676d41c 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -56,11 +56,11 @@ __FBSDID("$FreeBSD$"); * We also modify the collation table test functions to search the thread-local * table first and the global table second. */ -#define __collate_load_error (table->__collate_load_error) #define __collate_substitute_nontrivial (table->__collate_substitute_nontrivial) #define __collate_substitute_table_ptr (table->__collate_substitute_table_ptr) #define __collate_char_pri_table_ptr (table->__collate_char_pri_table_ptr) #define __collate_chain_pri_table (table->__collate_chain_pri_table) +int __collate_load_error; struct xlocale_collate __xlocale_global_collate = { @@ -109,7 +109,9 @@ __collate_load(const char *encoding, locale_t unused) int __collate_load_tables(const char *encoding) { - return __collate_load_tables_l(encoding, &__xlocale_global_collate); + int ret = __collate_load_tables_l(encoding, &__xlocale_global_collate); + __collate_load_error = __xlocale_global_collate.__collate_load_error; + return ret; } int @@ -123,7 +125,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table) /* 'encoding' must be already checked. */ if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) { - __collate_load_error = 1; + table->__collate_load_error = 1; return (_LDP_CACHE); } @@ -240,7 +242,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table) break; } } - __collate_load_error = 0; + table->__collate_load_error = 0; return (_LDP_LOADED); } diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index f036bbc..3ffb649 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -67,7 +67,6 @@ extern _RuneLocale *_Read_RuneMagi(FILE *); static int __setrunelocale(struct xlocale_ctype *l, const char *); -#define __collate_load_error (table->__collate_load_error) #define __collate_substitute_nontrivial (table->__collate_substitute_nontrivial) #define __collate_substitute_table_ptr (table->__collate_substitute_table_ptr) #define __collate_char_pri_table_ptr (table->__collate_char_pri_table_ptr) -- cgit v1.1 From bc71506d20005074684c1f3cc0fb5a60aeb26953 Mon Sep 17 00:00:00 2001 From: davidxu Date: Tue, 10 Jul 2012 01:47:11 +0000 Subject: Executing CPUID with EAX set to 1 to actually get feature flags. PR: 169730 --- lib/libc/i386/gen/getcontextx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/i386/gen/getcontextx.c b/lib/libc/i386/gen/getcontextx.c index 5908ce7..2d3b562 100644 --- a/lib/libc/i386/gen/getcontextx.c +++ b/lib/libc/i386/gen/getcontextx.c @@ -68,7 +68,7 @@ __getcontextx_size(void) " movl %%ebx,%1\n" " popl %%ebx\n" : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3]) - : "0" (0x0)); + : "0" (0x1)); if ((p[2] & CPUID2_OSXSAVE) != 0) { __asm __volatile( " pushl %%ebx\n" -- cgit v1.1 From 9ca1308bfb634fec0f594911944b51b4b01a5331 Mon Sep 17 00:00:00 2001 From: lstewart Date: Tue, 10 Jul 2012 08:31:28 +0000 Subject: Move the ffclock symbols from FBSD_1.2 to FBSD_1.3 where they should have been put initially. They were added to head during development of 10-CURRENT, not 9-CURRENT. Submitted by: glebius Reviewed by: kib --- lib/libc/sys/Symbol.map | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index f1c1567..6888ea0 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -365,9 +365,6 @@ FBSD_1.2 { cap_getmode; cap_new; cap_getrights; - ffclock_getcounter; - ffclock_getestimate; - ffclock_setestimate; getloginclass; pdfork; pdgetpid; @@ -382,6 +379,9 @@ FBSD_1.2 { }; FBSD_1.3 { + ffclock_getcounter; + ffclock_getestimate; + ffclock_setestimate; posix_fadvise; }; -- cgit v1.1 From 5d06c100811722500240ff513611a3a7c09eb939 Mon Sep 17 00:00:00 2001 From: brueffer Date: Sun, 15 Jul 2012 11:52:24 +0000 Subject: Jump to the failed label instead of doing cleanup ourselves. Obtained from: DragonFly BSD MFC after: 2 weeks --- lib/libc/rpc/getnetpath.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c index d1ea554..92eae95 100644 --- a/lib/libc/rpc/getnetpath.c +++ b/lib/libc/rpc/getnetpath.c @@ -99,9 +99,8 @@ setnetpath() return (NULL); } if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) { - free(np_sessionp); syslog (LOG_ERR, "rpc: failed to open " NETCONFIG); - return (NULL); + goto failed; } np_sessionp->valid = NP_VALID; np_sessionp->ncp_list = NULL; -- cgit v1.1 From a6e30f9565722c5df66277a5e22c7ea869c760d4 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 15 Jul 2012 20:39:21 +0000 Subject: libc: Remove some unused strings from getaddrinfo(). --- lib/libc/net/getaddrinfo.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index dc2641f..d6feb71 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -155,7 +155,6 @@ struct explore { int e_af; int e_socktype; int e_protocol; - const char *e_protostr; int e_wild; #define WILD_AF(ex) ((ex)->e_wild & 0x01) #define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) @@ -164,21 +163,21 @@ struct explore { static const struct explore explore[] = { #if 0 - { PF_LOCAL, ANY, ANY, NULL, 0x01 }, + { PF_LOCAL, ANY, ANY, 0x01 }, #endif #ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 }, - { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 }, - { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, + { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, + { PF_INET6, SOCK_STREAM, IPPROTO_TCP, 0x07 }, + { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, + { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, + { PF_INET6, SOCK_RAW, ANY, 0x05 }, #endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 }, - { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 }, - { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, - { -1, 0, 0, NULL, 0 }, + { PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, + { PF_INET, SOCK_STREAM, IPPROTO_TCP, 0x07 }, + { PF_INET, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, + { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, + { PF_INET, SOCK_RAW, ANY, 0x05 }, + { -1, 0, 0, 0 }, }; #ifdef INET6 -- cgit v1.1 From c9ba4f7b25ec65c1aba9ca25cfd5978e43d00fba Mon Sep 17 00:00:00 2001 From: emax Date: Wed, 18 Jul 2012 15:52:09 +0000 Subject: Return zero from get_addrselectpolicy() when no source-address-selection policy is installed. MFC after: 1 week --- lib/libc/net/getaddrinfo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index d6feb71..d11ff78 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -692,6 +692,8 @@ get_addrselectpolicy(struct policyhead *head) if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) return (0); + if (l == 0) + return (0); if ((buf = malloc(l)) == NULL) return (0); if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) { -- cgit v1.1 From d950d8a13fa882cc5c23240d4fa991db5fee3ef6 Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 19 Jul 2012 10:23:59 +0000 Subject: Document F_DUPFD_CLOEXEC. Also provide some wording changes for F_DUPFD to make it less confusing, at least for me. MFC after: 1 week --- lib/libc/sys/fcntl.2 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index beceb72..0844e87 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -28,7 +28,7 @@ .\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94 .\" $FreeBSD$ .\" -.Dd January 28, 2012 +.Dd July 18, 2012 .Dt FCNTL 2 .Os .Sh NAME @@ -54,7 +54,7 @@ Depending on the value of .Fn fcntl can take an additional third argument .Fa "int arg" . -.Bl -tag -width F_GETOWNX +.Bl -tag -width F_DUPFD_CLOEXEC .It Dv F_DUPFD Return a new descriptor as follows: .Pp @@ -73,11 +73,22 @@ Same access mode (read, write or read/write). Same file status flags (i.e., both file descriptors share the same file status flags). .It -The close-on-exec flag associated with the new file descriptor -is set to remain open across +The close-on-exec flag +.Dv FD_CLOEXEC +associated with the new file descriptor is cleared, so the file descriptor is +to remain open across .Xr execve 2 system calls. .El +.It Dv F_DUPFD_CLOEXEC +Like +.Dv F_DUPFD , +but the +.Dv FD_CLOEXEC +flag associated with the new file descriptor is set, so the file descriptor +is closed when +.Xr execve 2 +system call executes. .It Dv F_DUP2FD It is functionally equivalent to .Bd -literal -offset indent -- cgit v1.1 From e04825c920221bef72b0adc4386073fe8e20a946 Mon Sep 17 00:00:00 2001 From: kib Date: Sat, 21 Jul 2012 13:02:11 +0000 Subject: (Incomplete) fixes for symbols visibility issues and style in fcntl.h. Append '__' prefix to the tag of struct oflock, and put it under BSD namespace. Structure is needed both by libc and kernel, thus cannot be hidden under #ifdef _KERNEL. Move a set of non-standard F_* and O_* constants into BSD namespace. SUSv4 explicitely allows implemenation to pollute F_* and O_* names after fcntl.h is included, but it costs us nothing to adhere to the specification if exact POSIX compliance level is requested by user code. Change some spaces after #define to tabs. Noted by and discussed with: bde MFC after: 1 week --- lib/libc/sys/fcntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/fcntl.c b/lib/libc/sys/fcntl.c index 470f8ab..480cc40 100644 --- a/lib/libc/sys/fcntl.c +++ b/lib/libc/sys/fcntl.c @@ -41,7 +41,7 @@ __fcntl_compat(int fd, int cmd, ...) { va_list args; long arg; - struct oflock ofl; + struct __oflock ofl; struct flock *flp; int res; -- cgit v1.1 From 430cf8efee0b56a369f33b1a60883a776f71a1d2 Mon Sep 17 00:00:00 2001 From: issyl0 Date: Wed, 25 Jul 2012 22:17:44 +0000 Subject: Add a new man page containing details of new locale-specific functions for wctype.h, iswalnum_l(3). Add it and its functions to the Makefile. Reviewed by: gavin, jilles Approved by: theraven MFC after: 5 days --- lib/libc/locale/Makefile.inc | 15 +++- lib/libc/locale/iswalnum_l.3 | 168 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 lib/libc/locale/iswalnum_l.3 (limited to 'lib/libc') diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index adae8bd..8f3c4c6 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -30,7 +30,8 @@ MAN+= btowc.3 \ ctype.3 digittoint.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \ isdigit.3 isgraph.3 isideogram.3 islower.3 isphonogram.3 isprint.3 \ ispunct.3 isrune.3 isspace.3 isspecial.3 \ - isupper.3 iswalnum.3 isxdigit.3 localeconv.3 mblen.3 mbrlen.3 \ + isupper.3 iswalnum.3 iswalnum_l.3 isxdigit.3 \ + localeconv.3 mblen.3 mbrlen.3 \ mbrtowc.3 \ mbsinit.3 \ mbsrtowcs.3 mbstowcs.3 mbtowc.3 multibyte.3 \ @@ -53,6 +54,18 @@ MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswascii.3 iswalnum.3 iswblank.3 \ iswalnum.3 iswphonogram.3 iswalnum.3 iswprint.3 iswalnum.3 iswpunct.3 \ iswalnum.3 iswrune.3 iswalnum.3 iswspace.3 iswalnum.3 iswspecial.3 \ iswalnum.3 iswupper.3 iswalnum.3 iswxdigit.3 +MLINKS+=iswalnum_l.3 iswalpha_l.3 iswalnum_l.3 iswcntrl_l.3 \ + iswalnum_l.3 iswctype_l.3 iswalnum_l.3 iswdigit_l.3 \ + iswalnum_l.3 iswgraph_l.3 iswalnum_l.3 iswlower_l.3 \ + iswalnum_l.3 iswprint_l.3 iswalnum_l.3 iswpunct_l.3 \ + iswalnum_l.3 iswspace_l.3 iswalnum_l.3 iswupper_l.3 \ + iswalnum_l.3 iswxdigit_l.3 iswalnum_l.3 towlower_l.3 \ + iswalnum_l.3 towupper_l.3 iswalnum_l.3 wctype_l.3 \ + iswalnum_l.3 iswblank_l.3 iswalnum_l.3 iswhexnumber_l.3 \ + iswalnum_l.3 iswideogram_l.3 iswalnum_l.3 iswnumber_l.3 \ + iswalnum_l.3 iswphonogram_l.3 iswalnum_l.3 iswrune_l.3 \ + iswalnum_l.3 iswspecial_l.3 iswalnum_l.3 nextwctype_l.3 \ + iswalnum_l.3 towctrans_l.3 iswalnum_l.3 wctrans_l.3 MLINKS+=isxdigit.3 ishexnumber.3 MLINKS+=mbsrtowcs.3 mbsnrtowcs.3 MLINKS+=wcsrtombs.3 wcsnrtombs.3 diff --git a/lib/libc/locale/iswalnum_l.3 b/lib/libc/locale/iswalnum_l.3 new file mode 100644 index 0000000..679a2dd --- /dev/null +++ b/lib/libc/locale/iswalnum_l.3 @@ -0,0 +1,168 @@ +.\" Copyright (c) 2012 Isabell Long +.\" 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 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 AUTHOR 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. +.\" +.\" $FreeBSD$ +.\" +.Dt ISWALNUM_L 3 +.Dd July 25, 2012 +.Os +.Sh NAME +.Nm iswalnum_l , +.Nm iswalpha_l , +.Nm iswcntrl_l , +.Nm iswctype_l , +.Nm iswdigit_l , +.Nm iswgraph_l , +.Nm iswlower_l , +.Nm iswprint_l , +.Nm iswpunct_l , +.Nm iswspace_l , +.Nm iswupper_l , +.Nm iswxdigit_l , +.Nm towlower_l , +.Nm towupper_l , +.Nm wctype_l , +.Nm iswblank_l , +.Nm iswhexnumber_l , +.Nm iswideogram_l , +.Nm iswnumber_l , +.Nm iswphonogram_l , +.Nm iswrune_l , +.Nm iswspecial_l , +.Nm nextwctype_l , +.Nm towctrans_l , +.Nm wctrans_l +.Nd wide character classification utilities +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wctype.h +.Ft int +.Fn iswalnum_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswalpha_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswcntrl_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswctype_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswdigit_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswgraph_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswlower_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswprint_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswpunct_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswspace_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswupper_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswxdigit_l "wint_t wc" "locale_t loc" +.Ft wint_t +.Fn towlower_l "wint_t wc" "locale_t loc" +.Ft wint_t +.Fn towupper_l "wint_t wc" "locale_t loc" +.Ft wctype_t +.Fn wctype_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswblank_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswhexnumber_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswideogram_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswnumber_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswphonogram_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswrune_l "wint_t wc" "locale_t loc" +.Ft int +.Fn iswspecial_l "wint_t wc" "locale_t loc" +.Ft wint_t +.Fn nextwctype_l "wint_t wc" "locale_t loc" +.Ft wint_t +.Fn towctrans_l "wint_t wc" "wctrans_t" "locale_t loc" +.Ft wctrans_t +.Fn wctrans_l "const char *" "locale_t loc" +.Sh DESCRIPTION +The above functions are character classification utility functions, +for use with wide characters +.Vt ( wchar_t +or +.Vt wint_t ) +in the locale +.Fa loc . +They behave in the same way as the versions without the _l suffix, but use +the specified locale rather than the global or per-thread locale. +These functions may be implemented as inline functions in +.In wctype.h +and as functions in the C library. +See the specific manual pages for more information. +.Sh RETURN VALUES +These functions return the same things as their non-locale versions. +If the locale is invalid, their behaviors are undefined. +.Sh SEE ALSO +.Xr iswalnum 3 , +.Xr iswalpha 3 , +.Xr iswblank 3 , +.Xr iswcntrl 3 , +.Xr iswctype 3 , +.Xr iswdigit 3 , +.Xr iswgraph 3 , +.Xr iswhexnumber 3 , +.Xr iswideogram 3 , +.Xr iswlower 3 , +.Xr iswnumber 3 , +.Xr iswphonogram 3 , +.Xr iswprint 3 , +.Xr iswpunct 3 , +.Xr iswrune 3 , +.Xr iswspace 3 , +.Xr iswspecial 3 , +.Xr iswupper 3 , +.Xr iswxdigit 3 , +.Xr nextwctype 3 , +.Xr towctrans 3 , +.Xr towlower 3 , +.Xr towupper 3 , +.Xr wctrans 3 , +.Xr wctype 3 +.Sh STANDARDS +These functions conform to +.St -p1003.1-2008 , +except for +.Fn iswascii_l , +.Fn iswhexnumber_l , +.Fn iswideogram_l , +.Fn iswphonogram_l , +.Fn iswrune_l , +.Fn iswspecial_l +and +.Fn nextwctype_l +which are +.Fx +extensions. -- cgit v1.1 From 99f0d16551073e4c685d980e14eaaf27ce5754be Mon Sep 17 00:00:00 2001 From: pluknet Date: Thu, 26 Jul 2012 12:04:11 +0000 Subject: Update the 'C1x draft' reference to '.St -isoC-2011' mdoc macro. Reviewed by: theraven MFC after: 1 week --- lib/libc/stdlib/at_quick_exit.3 | 3 ++- lib/libc/stdlib/quick_exit.3 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/at_quick_exit.3 b/lib/libc/stdlib/at_quick_exit.3 index a75c0c0..c430154 100644 --- a/lib/libc/stdlib/at_quick_exit.3 +++ b/lib/libc/stdlib/at_quick_exit.3 @@ -58,4 +58,5 @@ function returns the value 0 if successful and a non-zero value on failure. .Sh STANDARDS The .Fn at_quick_exit -function conforms to the C1x draft specification. +function conforms to +.St -isoC-2011 . diff --git a/lib/libc/stdlib/quick_exit.3 b/lib/libc/stdlib/quick_exit.3 index 06fde8b..f2ea379 100644 --- a/lib/libc/stdlib/quick_exit.3 +++ b/lib/libc/stdlib/quick_exit.3 @@ -54,4 +54,5 @@ function does not return. .Sh STANDARDS The .Fn quick_exit -function conforms to the C1x draft specification. +function conforms to +.St -isoC-2011 . -- cgit v1.1 From dcf3898747d71456dfeea167cdaa723c9368ba2f Mon Sep 17 00:00:00 2001 From: joel Date: Thu, 26 Jul 2012 14:46:19 +0000 Subject: Start manpage with Dd macro and also remove a trailing whitespace while here. --- lib/libc/locale/iswalnum_l.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/iswalnum_l.3 b/lib/libc/locale/iswalnum_l.3 index 679a2dd..21ee48f 100644 --- a/lib/libc/locale/iswalnum_l.3 +++ b/lib/libc/locale/iswalnum_l.3 @@ -24,8 +24,8 @@ .\" .\" $FreeBSD$ .\" -.Dt ISWALNUM_L 3 .Dd July 25, 2012 +.Dt ISWALNUM_L 3 .Os .Sh NAME .Nm iswalnum_l , @@ -161,7 +161,7 @@ except for .Fn iswphonogram_l , .Fn iswrune_l , .Fn iswspecial_l -and +and .Fn nextwctype_l which are .Fx -- cgit v1.1 From 4e7839007ab707452aab4262d6fee9846bb28767 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 27 Jul 2012 10:41:53 +0000 Subject: Document F_DUP2FD_CLOEXEC. MFC after: 1 week --- lib/libc/sys/fcntl.2 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index 0844e87..63d6510 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -28,7 +28,7 @@ .\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94 .\" $FreeBSD$ .\" -.Dd July 18, 2012 +.Dd July 27, 2012 .Dt FCNTL 2 .Os .Sh NAME @@ -54,7 +54,7 @@ Depending on the value of .Fn fcntl can take an additional third argument .Fa "int arg" . -.Bl -tag -width F_DUPFD_CLOEXEC +.Bl -tag -width F_DUP2FD_CLOEXEC .It Dv F_DUPFD Return a new descriptor as follows: .Pp @@ -94,13 +94,23 @@ It is functionally equivalent to .Bd -literal -offset indent dup2(fd, arg) .Ed +.It Dv F_DU2PFD_CLOEXEC +Like +.Dv F_DUP2FD , +but the +.Dv FD_CLOEXEC +flag associated with the new file descriptor is set. .Pp The .Dv F_DUP2FD -constant is not portable, so it should not be used if portability is needed. +and +.Dv F_DUP2DF_CLOEXEC +constants are not portable, so they should not be used if +portability is needed. Use .Fn dup2 -instead. +instead of +.Dv F_DUP2FD . .It Dv F_GETFD Get the close-on-exec flag associated with the file descriptor .Fa fd -- cgit v1.1 From 6856a4229035b7ffb57cf926225c8029989e0625 Mon Sep 17 00:00:00 2001 From: emaste Date: Fri, 27 Jul 2012 21:38:14 +0000 Subject: Correct BUGS description of static buffer use Since r142667 strerror has unconditionally returned a pointer to a static buffer. MFC after: 1 week --- lib/libc/string/strerror.3 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3 index 5961a84..cc25602 100644 --- a/lib/libc/string/strerror.3 +++ b/lib/libc/string/strerror.3 @@ -174,10 +174,10 @@ function was implemented in by .An Wes Peters Aq wes@FreeBSD.org . .Sh BUGS -For unknown error numbers, the +The .Fn strerror -function will return its result in a static buffer which -may be overwritten by subsequent calls. +function returns its result in a static buffer which +will be overwritten by subsequent calls. .Pp The return type for .Fn strerror -- cgit v1.1 From 6a683d47fc64b7528b27294edebfc2000aebb8e6 Mon Sep 17 00:00:00 2001 From: issyl0 Date: Mon, 30 Jul 2012 20:56:19 +0000 Subject: Add more locale-specific functions to the relevant man pages and Makefile: - lib/libc/locale/islower.3 - lib/libc/locale/ispunct.3 - lib/libc/locale/nl_langinfo.3 - lib/libc/locale/isgraph.3 - lib/libc/locale/isspace.3 Reviewed by: bz Approved by: theraven MFC after: 5 days --- lib/libc/locale/Makefile.inc | 5 +++++ lib/libc/locale/isgraph.3 | 20 +++++++++++++++++--- lib/libc/locale/islower.3 | 19 ++++++++++++++++--- lib/libc/locale/ispunct.3 | 20 +++++++++++++++++--- lib/libc/locale/isspace.3 | 20 +++++++++++++++++--- lib/libc/locale/nl_langinfo.3 | 16 ++++++++++++++-- 6 files changed, 86 insertions(+), 14 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index 8f3c4c6..f2161be 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -47,6 +47,11 @@ MAN+= big5.5 euc.5 gb18030.5 gb2312.5 gbk.5 mskanji.5 utf8.5 MLINKS+=btowc.3 wctob.3 MLINKS+=isdigit.3 isnumber.3 +MLINKS+=isgraph.3 isgraph_l.3 +MLINKS+=islower.3 islower_l.3 +MLINKS+=ispunct.3 ispunct_l.3 +MLINKS+=isspace.3 isspace_l.3 +MLINKS+=nl_langinfo.3 nl_langinfo_l.3 MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswascii.3 iswalnum.3 iswblank.3 \ iswalnum.3 iswcntrl.3 iswalnum.3 iswdigit.3 iswalnum.3 iswgraph.3 \ iswalnum.3 iswhexnumber.3 \ diff --git a/lib/libc/locale/isgraph.3 b/lib/libc/locale/isgraph.3 index bedf31e..95a8319 100644 --- a/lib/libc/locale/isgraph.3 +++ b/lib/libc/locale/isgraph.3 @@ -32,7 +32,7 @@ .\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd July 30, 2012 .Dt ISGRAPH 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .In ctype.h .Ft int .Fn isgraph "int c" +.Ft int +.Fn isgraph_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isgraph @@ -79,11 +81,19 @@ In the ASCII character set, this includes the following characters .It "\&166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''" Ta "172\ ``z''" .It "\&173\ ``{''" Ta "174\ ``|''" Ta "175\ ``}''" Ta "176\ ``~''" Ta \& .El +.Pp +The +.Fn isgraph_l +function takes an explicit locale argument, whereas the +.Fn isgraph +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isgraph -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isgraph_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -103,3 +113,7 @@ The .Fn isgraph function conforms to .St -isoC . +The +.Fn isgraph_l +function conforms to +.St -p1003.1-2008 . diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3 index 987ff59..14c3b5f 100644 --- a/lib/libc/locale/islower.3 +++ b/lib/libc/locale/islower.3 @@ -32,7 +32,7 @@ .\" @(#)islower.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd July 30, 2012 .Dt ISLOWER 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .In ctype.h .Ft int .Fn islower "int c" +.Ft int +.Fn islower_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn islower @@ -63,11 +65,18 @@ In the ASCII character set, this includes the following characters .It "\&165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''" .It "\&172\ ``z''" Ta \& Ta \& Ta \& Ta \& .El +The +.Fn islower_l +function takes an explicit locale argument, whereas the +.Fn islower +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn islower -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn islower_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -88,3 +97,7 @@ The .Fn islower function conforms to .St -isoC . +The +.Fn islower_l +function conforms to +.St -p1003.1-2008 . diff --git a/lib/libc/locale/ispunct.3 b/lib/libc/locale/ispunct.3 index 8fcfe54..c06b25d 100644 --- a/lib/libc/locale/ispunct.3 +++ b/lib/libc/locale/ispunct.3 @@ -32,7 +32,7 @@ .\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd July 30, 2012 .Dt ISPUNCT 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .In ctype.h .Ft int .Fn ispunct "int c" +.Ft int +.Fn ispunct_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn ispunct @@ -69,11 +71,19 @@ In the ASCII character set, this includes the following characters .It "\&136\ ``^''" Ta "137\ ``_''" Ta "140\ ```''" Ta "173\ ``{''" Ta "174\ ``|''" .It "\&175\ ``}''" Ta "176\ ``~''" Ta \& Ta \& Ta \& .El +.Pp +The +.Fn ispunct_l +function takes an explicit locale argument, whereas the +.Fn ispunct +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn ispunct -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn ispunct_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -93,3 +103,7 @@ The .Fn ispunct function conforms to .St -isoC . +The +.Fn ispunct_l +function conforms to +.St -p1003.1-2008 . diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3 index 6dfeb5f..5dfd1b6 100644 --- a/lib/libc/locale/isspace.3 +++ b/lib/libc/locale/isspace.3 @@ -32,7 +32,7 @@ .\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 17, 2005 +.Dd July 30, 2012 .Dt ISSPACE 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .In ctype.h .Ft int .Fn isspace "int c" +.Ft int +.Fn isspace_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isspace @@ -60,11 +62,19 @@ The value of the argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +The +.Fn isspace_l +function takes an explicit locale argument, whereas the +.Fn isspace +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isspace -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isspace_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -85,3 +95,7 @@ The .Fn isspace function conforms to .St -isoC . +The +.Fn isspace_l +function conforms to +.St -p1003.1-2008 . diff --git a/lib/libc/locale/nl_langinfo.3 b/lib/libc/locale/nl_langinfo.3 index 789cac2..d8c01b2 100644 --- a/lib/libc/locale/nl_langinfo.3 +++ b/lib/libc/locale/nl_langinfo.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 3, 2001 +.Dd July 30, 2012 .Dt NL_LANGINFO 3 .Os .Sh NAME @@ -36,11 +36,16 @@ .In langinfo.h .Ft char * .Fn nl_langinfo "nl_item item" +.Ft char * +.Fn nl_langinfo_l "nl_item item" "locale_t loc" .Sh DESCRIPTION The .Fn nl_langinfo function returns a pointer to a string containing information relevant to -the particular language or cultural area defined in the program's locale. +the particular language or cultural area defined in the program or thread's +locale, or in the case of +.Fn nl_langinfo_l , +the locale passed as the second argument. The manifest constant names and values of .Fa item are defined in @@ -60,6 +65,9 @@ In a locale where langinfo data is not defined, returns a pointer to the corresponding string in the .Tn POSIX locale. +.Fn nl_langinfo_l +returns the same values as +.Fn nl_langinfo . In all locales, .Fn nl_langinfo returns a pointer to an empty string if @@ -83,6 +91,10 @@ The .Fn nl_langinfo function conforms to .St -susv2 . +The +.Fn nl_langinfo_l +function conforms to +.St -p1003.1-2008 . .Sh HISTORY The .Fn nl_langinfo -- cgit v1.1 From 84ed784b36ca5c56410485c6fcfc66e2d37a82d1 Mon Sep 17 00:00:00 2001 From: joel Date: Mon, 30 Jul 2012 21:02:44 +0000 Subject: Remove trailing whitespace. --- lib/libc/locale/islower.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3 index 14c3b5f..0b340da 100644 --- a/lib/libc/locale/islower.3 +++ b/lib/libc/locale/islower.3 @@ -69,7 +69,7 @@ The .Fn islower_l function takes an explicit locale argument, whereas the .Fn islower -function uses the current global or per-thread locale. +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn islower -- cgit v1.1 From dc040356951ccf5c9e9fab8c348e87e5dcc818c1 Mon Sep 17 00:00:00 2001 From: delphij Date: Wed, 1 Aug 2012 00:21:55 +0000 Subject: Use calloc(). --- lib/libc/gen/fts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 153b8da..afaa057 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -134,9 +134,8 @@ fts_open(argv, options, compar) } /* Allocate/initialize the stream. */ - if ((priv = malloc(sizeof(*priv))) == NULL) + if ((priv = calloc(1, sizeof(*priv))) == NULL) return (NULL); - memset(priv, 0, sizeof(*priv)); sp = &priv->ftsp_fts; sp->fts_compar = compar; sp->fts_options = options; -- cgit v1.1 From 05000e5bd1001071522b669bef4e6844d1453f80 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 9 Aug 2012 15:04:06 +0000 Subject: nftw(): Do not check the maxfds argument against OPEN_MAX. Apart from the fact that nothing should have OPEN_MAX as a limit (as opposed to RLIMIT_NOFILE from getrlimit() or _SC_OPEN_MAX from sysconf()), POSIX does not require us to check this. PR: 95239 Submitted by: Todd Miller --- lib/libc/gen/nftw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c index 43110c1..e14d09e 100644 --- a/lib/libc/gen/nftw.c +++ b/lib/libc/gen/nftw.c @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, @@ -47,7 +46,7 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int, int error = 0, ftsflags, fnflag, postorder, sverrno; /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { + if (nfds < 1) { errno = EINVAL; return (-1); } -- cgit v1.1 From 01c6b906beb3f49fe7d799ffaa172f7b9d686595 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 9 Aug 2012 15:11:38 +0000 Subject: ftw(): Do not check the maxfds argument against OPEN_MAX. Apart from the fact that nothing should have OPEN_MAX as a limit (as opposed to RLIMIT_NOFILE from getrlimit() or _SC_OPEN_MAX from sysconf()), POSIX does not require us to check this. POSIX does have a requirement on the application that maxfds not exceed {OPEN_MAX}, but does not require the implementation to check it ("may fail"). PR: 95239 --- lib/libc/gen/ftw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c index bfaf121..253a295 100644 --- a/lib/libc/gen/ftw.c +++ b/lib/libc/gen/ftw.c @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), @@ -40,7 +39,7 @@ ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int error = 0, fnflag, sverrno; /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { + if (nfds < 1) { errno = EINVAL; return (-1); } -- cgit v1.1 From 278be30294f435b7b5e07d641af9c4c6b7dc3b95 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 9 Aug 2012 19:22:54 +0000 Subject: Refresh with OpenBSD RCS ID changes to reflect that we now have essentionally the same file. --- lib/libc/gen/nftw.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c index e14d09e..5bca2de 100644 --- a/lib/libc/gen/nftw.c +++ b/lib/libc/gen/nftw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $ */ +/* $OpenBSD: nftw.c,v 1.7 2006/03/31 19:41:44 millert Exp $ */ /* * Copyright (c) 2003, 2004 Todd C. Miller @@ -20,12 +20,6 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: nftw.c,v 1.4 2004/07/07 16:05:23 millert Exp $"; -#endif /* LIBC_SCCS and not lint */ -#endif - #include __FBSDID("$FreeBSD$"); -- cgit v1.1 From 4d961f95f8cad07145afdb640f32972b8b61fbaa Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 9 Aug 2012 22:05:40 +0000 Subject: nftw(): POSIX says directories causing loops should be silently skipped. Formerly, loops caused nftw() to abort the traversal with ELOOP. --- lib/libc/gen/nftw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c index 5bca2de..a338e5a 100644 --- a/lib/libc/gen/nftw.c +++ b/lib/libc/gen/nftw.c @@ -65,6 +65,8 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int, continue; fnflag = FTW_D; break; + case FTS_DC: + continue; case FTS_DNR: fnflag = FTW_DNR; break; @@ -87,9 +89,6 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int, case FTS_SLNONE: fnflag = FTW_SLN; break; - case FTS_DC: - errno = ELOOP; - /* FALLTHROUGH */ default: error = -1; goto done; -- cgit v1.1 From 362478d3c0bd28967053d21d4ba2a88a97feae01 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 11 Aug 2012 12:07:24 +0000 Subject: Rename aux.c to auxv.c. On Windows, AUX is the auxiliary device, usually pointing to COM1. Therefore it is forbidden to create a file named aux.c. To make it a bit easier for Windows users to check out our source code, rename this file to auxv.c. MFC after: 1 month Discussed with: kib Suggested by: Eric van Gyzen --- lib/libc/gen/Makefile.inc | 2 +- lib/libc/gen/aux.c | 186 ---------------------------------------------- lib/libc/gen/auxv.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 187 deletions(-) delete mode 100644 lib/libc/gen/aux.c create mode 100644 lib/libc/gen/auxv.c (limited to 'lib/libc') diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 98e8183..2e7a31c 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -7,7 +7,7 @@ SRCS+= __getosreldate.c __xuname.c \ _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \ _thread_init.c \ - alarm.c arc4random.c assert.c aux.c basename.c check_utility_compat.c \ + alarm.c arc4random.c assert.c auxv.c basename.c check_utility_compat.c \ clock.c closedir.c confstr.c \ crypt.c ctermid.c daemon.c devname.c dirfd.c dirname.c disklabel.c \ dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \ diff --git a/lib/libc/gen/aux.c b/lib/libc/gen/aux.c deleted file mode 100644 index 3767ac0..0000000 --- a/lib/libc/gen/aux.c +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * Copyright 2010, 2012 Konstantin Belousov . - * 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 -__FBSDID("$FreeBSD$"); - -#include "namespace.h" -#include -#include -#include -#include -#include -#include "un-namespace.h" -#include "libc_private.h" - -extern char **environ; -extern int _DYNAMIC; -#pragma weak _DYNAMIC - -void *__elf_aux_vector; -static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT; - -static void -init_aux_vector_once(void) -{ - Elf_Addr *sp; - - sp = (Elf_Addr *)environ; - while (*sp++ != 0) - ; - __elf_aux_vector = (Elf_Auxinfo *)sp; -} - -void -__init_elf_aux_vector(void) -{ - - if (&_DYNAMIC != NULL) - return; - _once(&aux_vector_once, init_aux_vector_once); -} - -static pthread_once_t aux_once = PTHREAD_ONCE_INIT; -static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; -static char *canary, *pagesizes; -static void *timekeep; - -static void -init_aux(void) -{ - Elf_Auxinfo *aux; - - for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) { - switch (aux->a_type) { - case AT_CANARY: - canary = (char *)(aux->a_un.a_ptr); - break; - - case AT_CANARYLEN: - canary_len = aux->a_un.a_val; - break; - - case AT_PAGESIZES: - pagesizes = (char *)(aux->a_un.a_ptr); - break; - - case AT_PAGESIZESLEN: - pagesizes_len = aux->a_un.a_val; - break; - - case AT_PAGESZ: - pagesize = aux->a_un.a_val; - break; - - case AT_OSRELDATE: - osreldate = aux->a_un.a_val; - break; - - case AT_NCPUS: - ncpus = aux->a_un.a_val; - break; - - case AT_TIMEKEEP: - timekeep = aux->a_un.a_ptr; - break; - } - } -} - -int -_elf_aux_info(int aux, void *buf, int buflen) -{ - int res; - - __init_elf_aux_vector(); - if (__elf_aux_vector == NULL) - return (ENOSYS); - _once(&aux_once, init_aux); - - switch (aux) { - case AT_CANARY: - if (canary != NULL && canary_len >= buflen) { - memcpy(buf, canary, buflen); - memset(canary, 0, canary_len); - canary = NULL; - res = 0; - } else - res = ENOENT; - break; - case AT_PAGESIZES: - if (pagesizes != NULL && pagesizes_len >= buflen) { - memcpy(buf, pagesizes, buflen); - res = 0; - } else - res = ENOENT; - break; - - case AT_PAGESZ: - if (buflen == sizeof(int)) { - if (pagesize != 0) { - *(int *)buf = pagesize; - res = 0; - } else - res = ENOENT; - } else - res = EINVAL; - break; - case AT_OSRELDATE: - if (buflen == sizeof(int)) { - if (osreldate != 0) { - *(int *)buf = osreldate; - res = 0; - } else - res = ENOENT; - } else - res = EINVAL; - break; - case AT_NCPUS: - if (buflen == sizeof(int)) { - if (ncpus != 0) { - *(int *)buf = ncpus; - res = 0; - } else - res = ENOENT; - } else - res = EINVAL; - break; - case AT_TIMEKEEP: - if (buflen == sizeof(void *)) { - if (timekeep != NULL) { - *(void **)buf = timekeep; - res = 0; - } else - res = ENOENT; - } else - res = EINVAL; - break; - default: - res = ENOENT; - break; - } - return (res); -} diff --git a/lib/libc/gen/auxv.c b/lib/libc/gen/auxv.c new file mode 100644 index 0000000..3767ac0 --- /dev/null +++ b/lib/libc/gen/auxv.c @@ -0,0 +1,186 @@ +/*- + * Copyright 2010, 2012 Konstantin Belousov . + * 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 +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include +#include +#include +#include "un-namespace.h" +#include "libc_private.h" + +extern char **environ; +extern int _DYNAMIC; +#pragma weak _DYNAMIC + +void *__elf_aux_vector; +static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT; + +static void +init_aux_vector_once(void) +{ + Elf_Addr *sp; + + sp = (Elf_Addr *)environ; + while (*sp++ != 0) + ; + __elf_aux_vector = (Elf_Auxinfo *)sp; +} + +void +__init_elf_aux_vector(void) +{ + + if (&_DYNAMIC != NULL) + return; + _once(&aux_vector_once, init_aux_vector_once); +} + +static pthread_once_t aux_once = PTHREAD_ONCE_INIT; +static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; +static char *canary, *pagesizes; +static void *timekeep; + +static void +init_aux(void) +{ + Elf_Auxinfo *aux; + + for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) { + switch (aux->a_type) { + case AT_CANARY: + canary = (char *)(aux->a_un.a_ptr); + break; + + case AT_CANARYLEN: + canary_len = aux->a_un.a_val; + break; + + case AT_PAGESIZES: + pagesizes = (char *)(aux->a_un.a_ptr); + break; + + case AT_PAGESIZESLEN: + pagesizes_len = aux->a_un.a_val; + break; + + case AT_PAGESZ: + pagesize = aux->a_un.a_val; + break; + + case AT_OSRELDATE: + osreldate = aux->a_un.a_val; + break; + + case AT_NCPUS: + ncpus = aux->a_un.a_val; + break; + + case AT_TIMEKEEP: + timekeep = aux->a_un.a_ptr; + break; + } + } +} + +int +_elf_aux_info(int aux, void *buf, int buflen) +{ + int res; + + __init_elf_aux_vector(); + if (__elf_aux_vector == NULL) + return (ENOSYS); + _once(&aux_once, init_aux); + + switch (aux) { + case AT_CANARY: + if (canary != NULL && canary_len >= buflen) { + memcpy(buf, canary, buflen); + memset(canary, 0, canary_len); + canary = NULL; + res = 0; + } else + res = ENOENT; + break; + case AT_PAGESIZES: + if (pagesizes != NULL && pagesizes_len >= buflen) { + memcpy(buf, pagesizes, buflen); + res = 0; + } else + res = ENOENT; + break; + + case AT_PAGESZ: + if (buflen == sizeof(int)) { + if (pagesize != 0) { + *(int *)buf = pagesize; + res = 0; + } else + res = ENOENT; + } else + res = EINVAL; + break; + case AT_OSRELDATE: + if (buflen == sizeof(int)) { + if (osreldate != 0) { + *(int *)buf = osreldate; + res = 0; + } else + res = ENOENT; + } else + res = EINVAL; + break; + case AT_NCPUS: + if (buflen == sizeof(int)) { + if (ncpus != 0) { + *(int *)buf = ncpus; + res = 0; + } else + res = ENOENT; + } else + res = EINVAL; + break; + case AT_TIMEKEEP: + if (buflen == sizeof(void *)) { + if (timekeep != NULL) { + *(void **)buf = timekeep; + res = 0; + } else + res = ENOENT; + } else + res = EINVAL; + break; + default: + res = ENOENT; + break; + } + return (res); +} -- cgit v1.1 From 0c19fd41e201fbcbf4ce5cb949c595c01a9ad102 Mon Sep 17 00:00:00 2001 From: gonzo Date: Wed, 15 Aug 2012 03:09:00 +0000 Subject: Merging of projects/armv6, part 2 Handle TLS for ARMv6 and ARMv7 --- lib/libc/arm/gen/__aeabi_read_tp.S | 6 ++++++ lib/libc/arm/gen/_set_tp.c | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/arm/gen/__aeabi_read_tp.S b/lib/libc/arm/gen/__aeabi_read_tp.S index 228acff..c3ea99d 100644 --- a/lib/libc/arm/gen/__aeabi_read_tp.S +++ b/lib/libc/arm/gen/__aeabi_read_tp.S @@ -31,10 +31,16 @@ __FBSDID("$FreeBSD$"); #include ENTRY(__aeabi_read_tp) +#ifdef ARM_TP_ADDRESS ldr r0, .Larm_tp_address ldr r0, [r0] +#else + mrc p15, 0, r0, c13, c0, 3 +#endif RET +#ifdef ARM_TP_ADDRESS .Larm_tp_address: .word ARM_TP_ADDRESS +#endif diff --git a/lib/libc/arm/gen/_set_tp.c b/lib/libc/arm/gen/_set_tp.c index 44bbdd8..97cabec 100644 --- a/lib/libc/arm/gen/_set_tp.c +++ b/lib/libc/arm/gen/_set_tp.c @@ -35,5 +35,9 @@ void _set_tp(void *tp) { +#ifdef ARM_TP_ADDRESS *((struct tcb **)ARM_TP_ADDRESS) = tp; +#else + sysarch(ARM_SET_TP, tp); +#endif } -- cgit v1.1 From 8552821dd88e330e868645a6e497a39ff200eddd Mon Sep 17 00:00:00 2001 From: kevlo Date: Fri, 17 Aug 2012 01:05:56 +0000 Subject: Make 'junk' volatile so that compilers won't be tempted to optimize Reviewed by: ache MFC after: 3 days --- lib/libc/stdlib/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index f7be4a7..baae078 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -315,7 +315,7 @@ srandomdev() if (!done) { struct timeval tv; - unsigned long junk; + volatile unsigned long junk; gettimeofday(&tv, NULL); srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk); -- cgit v1.1 From 3f0806aa1fc8c8dc2f294421d558472faec7fd3f Mon Sep 17 00:00:00 2001 From: davidxu Date: Fri, 17 Aug 2012 02:26:31 +0000 Subject: Implement syscall clock_getcpuclockid2, so we can get a clock id for process, thread or others we want to support. Use the syscall to implement POSIX API clock_getcpuclock and pthread_getcpuclockid. PR: 168417 --- lib/libc/gen/Makefile.inc | 2 +- lib/libc/gen/Symbol.map | 1 + lib/libc/gen/clock_getcpuclockid.c | 39 ++++++++++++++++++++++++++++++++++++++ lib/libc/gen/sysconf.c | 4 ---- lib/libc/sys/Symbol.map | 3 +++ 5 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 lib/libc/gen/clock_getcpuclockid.c (limited to 'lib/libc') diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 2e7a31c..332165f 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -8,7 +8,7 @@ SRCS+= __getosreldate.c __xuname.c \ _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \ _thread_init.c \ alarm.c arc4random.c assert.c auxv.c basename.c check_utility_compat.c \ - clock.c closedir.c confstr.c \ + clock.c clock_getcpuclockid.c closedir.c confstr.c \ crypt.c ctermid.c daemon.c devname.c dirfd.c dirname.c disklabel.c \ dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \ exec.c fdevname.c feature_present.c fmtcheck.c fmtmsg.c fnmatch.c \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 356bee5..50a1d88 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -382,6 +382,7 @@ FBSD_1.2 { }; FBSD_1.3 { + clock_getcpuclockid; dirfd; fdlopen; __FreeBSD_libc_enter_restricted_mode; diff --git a/lib/libc/gen/clock_getcpuclockid.c b/lib/libc/gen/clock_getcpuclockid.c new file mode 100644 index 0000000..fc12bd6 --- /dev/null +++ b/lib/libc/gen/clock_getcpuclockid.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012 David Xu . + * 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 DANIEL EISCHEN 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 AUTHOR 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +clockid_t +clock_getcpuclockid(pid_t pid, clockid_t *clock_id) +{ + return clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id); +} diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 2d117b7..b7952b1 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -359,11 +359,7 @@ yesno: return (_POSIX_CLOCK_SELECTION); #endif case _SC_CPUTIME: -#if _POSIX_CPUTIME == 0 -#error "_POSIX_CPUTIME" -#else return (_POSIX_CPUTIME); -#endif #ifdef notdef case _SC_FILE_LOCKING: /* diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 6888ea0..008b8da 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -379,6 +379,7 @@ FBSD_1.2 { }; FBSD_1.3 { + clock_getcpuclockid2; ffclock_getcounter; ffclock_getestimate; ffclock_setestimate; @@ -490,6 +491,8 @@ FBSDprivate_1.0 { __sys_chown; _chroot; __sys_chroot; + _clock_getcpuclockid2; + __sys_clock_getcpuclockid2; _clock_getres; __sys_clock_getres; _clock_gettime; -- cgit v1.1 From 225cbe2a015f0724358f5647a1a626ffd4ed65f1 Mon Sep 17 00:00:00 2001 From: davidxu Date: Tue, 21 Aug 2012 09:17:13 +0000 Subject: Fix prototype. Also the function should return error code instead of -1 on error. --- lib/libc/gen/clock_getcpuclockid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/clock_getcpuclockid.c b/lib/libc/gen/clock_getcpuclockid.c index fc12bd6..f26035f 100644 --- a/lib/libc/gen/clock_getcpuclockid.c +++ b/lib/libc/gen/clock_getcpuclockid.c @@ -32,8 +32,10 @@ __FBSDID("$FreeBSD$"); #include #include -clockid_t +int clock_getcpuclockid(pid_t pid, clockid_t *clock_id) { - return clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id); + if (clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id)) + return (errno); + return (0); } -- cgit v1.1 From 20f511dcbd59a56810ab6e205bc067abb40a0c58 Mon Sep 17 00:00:00 2001 From: davidxu Date: Tue, 21 Aug 2012 09:18:28 +0000 Subject: Add manual pages for clock_getcpuclockid and pthread_getcpuclockid. --- lib/libc/gen/Makefile.inc | 2 +- lib/libc/gen/clock_getcpuclockid.3 | 95 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 lib/libc/gen/clock_getcpuclockid.3 (limited to 'lib/libc') diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 332165f..134ba34 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -52,7 +52,7 @@ SYM_MAPS+=${.CURDIR}/gen/Symbol.map .sinclude "${.CURDIR}/${LIBC_ARCH}/gen/Makefile.inc" MAN+= alarm.3 arc4random.3 \ - basename.3 check_utility_compat.3 clock.3 \ + basename.3 check_utility_compat.3 clock.3 clock_getcpuclockid.3 \ confstr.3 ctermid.3 daemon.3 devname.3 directory.3 dirname.3 \ dl_iterate_phdr.3 dladdr.3 dlinfo.3 dllockinit.3 dlopen.3 \ err.3 exec.3 \ diff --git a/lib/libc/gen/clock_getcpuclockid.3 b/lib/libc/gen/clock_getcpuclockid.3 new file mode 100644 index 0000000..8b624bf --- /dev/null +++ b/lib/libc/gen/clock_getcpuclockid.3 @@ -0,0 +1,95 @@ +.\" Copyright (c) 2012 David Xu +.\" 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 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 AUTHOR 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. +.\" +.\" Portions of this text are reprinted and reproduced in electronic form +.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- +.\" Portable Operating System Interface (POSIX), The Open Group Base +.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of +.\" Electrical and Electronics Engineers, Inc and The Open Group. In the +.\" event of any discrepancy between this version and the original IEEE and +.\" The Open Group Standard, the original IEEE and The Open Group Standard is +.\" the referee document. The original Standard can be obtained online at +.\" http://www.opengroup.org/unix/online.html. +.\" +.\" $FreeBSD$ +.\" +.Dd August 21, 2012 +.Dt CLOCK_GETCPUCLOCKID 3 +.Os +.Sh NAME +.Nm clock_getcpuclockid +.Nd access a process CPU-time clock +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Ft int +.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id" +.Sh DESCRIPTION +The +.Fn clock_getcpuclockid +returns the clock ID of the CPU-time clock of the process specified by +.Fa pid . +If the process described by +.Fa pid +exists and the calling process has permission, the clock ID of this +clock will be returned in +.Fa clock_id . +.Pp +If +.Fa pid +is zero, the +.Fn clock_getcpuclockid +function returns the clock ID of the CPU-time clock of the process +making the call, in +.Fa clock_id . +.Sh RETURN VALUES +Upon successful completion, +.Fn clock_getcpuclockid +returns zero; otherwise, an error number is returned to indicate the +error. +.Sh ERRORS +The clock_getcpuclockid() function will fail if: +.Bl -tag -width Er +.It Bq Er EPERM +The requesting process does not have permission to access the CPU-time +clock for the process. +.It Bq Er ESRCH +No process can be found corresponding to the process specified by +.Fa pid . +.El +.Sh SEE ALSO +.Xr clock_gettime 2 +.Sh STANDARDS +The +.Fn clock_getcpuclockid +function conform to +.St -p1003.1-2001 . +.Sh HISTORY +The +.Fn clock_getcpuclockid +function first appeared in +.Fx 10.0 . +.Sh AUTHORS +.An David Xu Aq davidxu@FreeBSD.org -- cgit v1.1 From 30d5057ff7e365096c74c1e9a76cf9b34930a29d Mon Sep 17 00:00:00 2001 From: joel Date: Tue, 21 Aug 2012 13:33:48 +0000 Subject: Remove trailing whitespace. --- lib/libc/gen/clock_getcpuclockid.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/clock_getcpuclockid.3 b/lib/libc/gen/clock_getcpuclockid.3 index 8b624bf..3d31993 100644 --- a/lib/libc/gen/clock_getcpuclockid.3 +++ b/lib/libc/gen/clock_getcpuclockid.3 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 21, 2012 +.Dd August 21, 2012 .Dt CLOCK_GETCPUCLOCKID 3 .Os .Sh NAME -- cgit v1.1 From 9e17ee4443c083ac0ae46c562bf5ae634d84252e Mon Sep 17 00:00:00 2001 From: zeising Date: Tue, 21 Aug 2012 16:35:14 +0000 Subject: Add missing .Pp macro. PR: docs/170380 Submitted by: Garrett Cooper Approved by: joel (mentor) --- lib/libc/sys/dup.2 | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/libc') diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index d2a4b7e..7a07c21 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -138,6 +138,7 @@ is not a valid active descriptor .It Bq Er EMFILE Too many descriptors are active. .El +.Pp The .Fn dup2 system call fails if: -- cgit v1.1 From 21bc2e377fee37fa4d9358a5d7e3ac32a8507eef Mon Sep 17 00:00:00 2001 From: pfg Date: Sat, 1 Sep 2012 02:56:17 +0000 Subject: Bring some changes from Bull's NFSv4 libtirpc implementation. We especifically ignored the glibc compatibility changes but this should help interaction with Solaris and Linux. ____ Fixed infinite loop in svc_run() author Steve Dickson Tue, 10 Jun 2008 12:35:52 -0500 (13:35 -0400) Fixed infinite loop in svc_run() ____ __rpc_taddr2uaddr_af() assumes the netbuf to always have a non-zero data. This is a bad assumption and can lead to a seg-fault. This patch adds a check for zero length and returns NULL when found. author Steve Dickson Mon, 27 Oct 2008 11:46:54 -0500 (12:46 -0400) ____ Changed clnt_spcreateerror() to return clearer and more concise error messages. author Steve Dickson Thu, 20 Nov 2008 08:55:31 -0500 (08:55 -0500) ____ Converted all uid and gid variables of the type uid_t and gid_t. author Steve Dickson Wed, 28 Jan 2009 12:44:46 -0500 (12:44 -0500) ____ libtirpc: set r_netid and r_owner in __rpcb_findaddr_timed These fields in the rpcbind GETADDR call are being passed uninitialized to CLNT_CALL. In the case of x86_64 at least, this usually leads to a segfault. On x86, it sometimes causes segfaults and other times causes garbage to be sent on the wire. rpcbind generally ignores the r_owner field for calls that come in over the wire, so it really doesn't matter what we send in that slot. We just need to send something. The reference implementation from Sun seems to send a blank string. Have ours follow suit. author Jeff Layton Fri, 13 Mar 2009 11:44:16 -0500 (12:44 -0400) ____ libtirpc: be sure to free cl_netid and cl_tp When creating a client with clnt_tli_create, it uses strdup to copy strings for these fields if nconf is passed in. clnt_dg_destroy frees these strings already. Make sure clnt_vc_destroy frees them in the same way. author Jeff Layton Fri, 13 Mar 2009 11:47:36 -0500 (12:47 -0400) Obtained from: Bull GNU/Linux NFSv4 Project MFC after: 3 weeks --- lib/libc/rpc/auth_unix.c | 10 ++++------ lib/libc/rpc/authunix_prot.c | 6 +++--- lib/libc/rpc/clnt_perror.c | 19 ++++++++++++++++--- lib/libc/rpc/clnt_vc.c | 4 ++++ lib/libc/rpc/rpc_generic.c | 9 +++++++-- lib/libc/rpc/rpc_soc.3 | 2 +- lib/libc/rpc/rpcb_clnt.c | 7 +++++++ lib/libc/rpc/svc_auth_unix.c | 2 +- lib/libc/rpc/svc_run.c | 5 ++--- 9 files changed, 45 insertions(+), 19 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index c0d2548..4d7a89b 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -94,10 +94,10 @@ struct audata { AUTH * authunix_create(machname, uid, gid, len, aup_gids) char *machname; - int uid; - int gid; + uid_t uid; + gid_t gid; int len; - int *aup_gids; + gid_t *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -207,9 +207,7 @@ authunix_create_default() abort(); if (ngids > NGRPS) ngids = NGRPS; - /* XXX: interface problem; those should all have been unsigned */ - auth = authunix_create(machname, (int)uid, (int)gid, ngids, - (int *)gids); + auth = authunix_create(machname, uid, gid, ngids, gids); free(gids); return (auth); } diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index 7699e28..dd84810 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -60,7 +60,7 @@ xdr_authunix_parms(xdrs, p) XDR *xdrs; struct authunix_parms *p; { - int **paup_gids; + gid_t **paup_gids; assert(xdrs != NULL); assert(p != NULL); @@ -69,8 +69,8 @@ xdr_authunix_parms(xdrs, p) if (xdr_u_long(xdrs, &(p->aup_time)) && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_int(xdrs, &(p->aup_uid)) - && xdr_int(xdrs, &(p->aup_gid)) + && xdr_u_int(xdrs, &(p->aup_uid)) + && xdr_u_int(xdrs, &(p->aup_gid)) && xdr_array(xdrs, (char **) paup_gids, &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { return (TRUE); diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index efe9043..87ad3c1 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -242,7 +242,7 @@ char * clnt_spcreateerror(s) const char *s; { - char *str; + char *str, *err; size_t len, i; assert(s != NULL); @@ -258,8 +258,21 @@ clnt_spcreateerror(s) switch (rpc_createerr.cf_stat) { case RPC_PMAPFAILURE: (void) strncat(str, " - ", len - 1); - (void) strncat(str, - clnt_sperrno(rpc_createerr.cf_error.re_status), len - 4); + err = clnt_sperrno(rpc_createerr.cf_error.re_status); + if (err) + (void) strncat(str, err+5, len-5); + switch(rpc_createerr.cf_error.re_status) { + case RPC_CANTSEND: + case RPC_CANTRECV: + i = strlen(str); + len -= i; + snprintf(str+i, len, ": errno %d (%s)", + rpc_createerr.cf_error.re_errno, + strerror(rpc_createerr.cf_error.re_errno)); + break; + default: + break; + } break; case RPC_SYSTEMERROR: diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index 07eff46..881f84d 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -672,6 +672,10 @@ clnt_vc_destroy(cl) if (ct->ct_addr.buf) free(ct->ct_addr.buf); mem_free(ct, sizeof(struct ct_data)); + if (cl->cl_netid && cl->cl_netid[0]) + mem_free(cl->cl_netid, strlen(cl->cl_netid) +1); + if (cl->cl_tp && cl->cl_tp[0]) + mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); mem_free(cl, sizeof(CLIENT)); mutex_unlock(&clnt_fd_lock); thr_sigsetmask(SIG_SETMASK, &(mask), NULL); diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index ab259d5..e592878 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -269,7 +269,8 @@ __rpc_getconfip(nettype) } while ((nconf = getnetconfig(confighandle)) != NULL) { if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { - if (strcmp(nconf->nc_proto, NC_TCP) == 0) { + if (strcmp(nconf->nc_proto, NC_TCP) == 0 && + netid_tcp == NULL) { netid_tcp = strdup(nconf->nc_netid); if (main_thread) netid_tcp_main = netid_tcp; @@ -277,7 +278,8 @@ __rpc_getconfip(nettype) thr_setspecific(tcp_key, (void *) netid_tcp); } else - if (strcmp(nconf->nc_proto, NC_UDP) == 0) { + if (strcmp(nconf->nc_proto, NC_UDP) == 0 && + netid_udp == NULL) { netid_udp = strdup(nconf->nc_netid); if (main_thread) netid_udp_main = netid_udp; @@ -616,6 +618,9 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) #endif u_int16_t port; + if (nbuf->len <= 0) + return NULL; + switch (af) { case AF_INET: sin = nbuf->buf; diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3 index 8dedaa8..a049a83 100644 --- a/lib/libc/rpc/rpc_soc.3 +++ b/lib/libc/rpc/rpc_soc.3 @@ -148,7 +148,7 @@ default authentication used by .Ft "AUTH *" .Xc .It Xo -.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids" +.Fn authunix_create "char *host" "uid_t uid" "gid_t gid" "int len" "gid_t *aup_gids" .Xc .Pp Create and return an diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index afef806..b123c32 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -770,6 +770,13 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) } parms.r_addr = NULL; + parms.r_netid = nconf->nc_netid; + + /* + * According to wire captures, the reference implementation + * (OpenSolaris) sends a blank string here too. + */ + parms.r_owner = ""; /* * Use default total timeout if no timeout is specified. diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index 4d6f102..f889d81 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -68,7 +68,7 @@ _svcauth_unix(rqst, msg) struct area { struct authunix_parms area_aup; char area_machname[MAX_MACHINE_NAME+1]; - int area_gids[NGRPS]; + gid_t area_gids[NGRPS]; } *area; u_int auth_len; size_t str_len, gid_len; diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index b4627d6..e6345a6 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -60,14 +60,13 @@ svc_run() fd_set readfds, cleanfds; struct timeval timeout; - timeout.tv_sec = 30; - timeout.tv_usec = 0; - for (;;) { rwlock_rdlock(&svc_fd_lock); readfds = svc_fdset; cleanfds = svc_fdset; rwlock_unlock(&svc_fd_lock); + timeout.tv_sec = 30; + timeout.tv_usec = 0; switch (_select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) { case -1: FD_ZERO(&readfds); -- cgit v1.1 From 02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 1 Sep 2012 14:45:15 +0000 Subject: Rework all non-contributed files that use `struct timezone'. This structure is not part of POSIX. According to POSIX, gettimeofday() has the following prototype: int gettimeofday(struct timeval *restrict tp, void *restrict tzp); Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is not used). Remove dead error handling code. Also use NULL for a nul-pointer instead of integer 0. While there, change all pieces of code that only use tv_sec to use time(3), as this provides less overhead. --- lib/libc/rpc/auth_des.c | 2 +- lib/libc/rpc/svc_auth_des.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c index 8f363e9..1b45c3b 100644 --- a/lib/libc/rpc/auth_des.c +++ b/lib/libc/rpc/auth_des.c @@ -286,7 +286,7 @@ authdes_marshal(AUTH *auth, XDR *xdrs) * Figure out the "time", accounting for any time difference * with the server if necessary. */ - (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL); + (void)gettimeofday(&ad->ad_timestamp, NULL); ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; while (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) { diff --git a/lib/libc/rpc/svc_auth_des.c b/lib/libc/rpc/svc_auth_des.c index de4d1b4..bd45f20 100644 --- a/lib/libc/rpc/svc_auth_des.c +++ b/lib/libc/rpc/svc_auth_des.c @@ -271,7 +271,7 @@ _svcauth_des(rqst, msg) debug("timestamp before last seen"); return (AUTH_REJECTEDVERF); /* replay */ } - (void) gettimeofday(¤t, (struct timezone *)NULL); + (void)gettimeofday(¤t, NULL); current.tv_sec -= window; /* allow for expiration */ if (!BEFORE(¤t, ×tamp)) { debug("timestamp expired"); -- cgit v1.1 From 2d0a5cb1e0e9d676c2b3e5999c28379692844fe9 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 4 Sep 2012 21:40:53 +0000 Subject: Add a prominent warning about these functions' unsuitability for cryptographic purposes, and recommend using arc4random(3) instead. --- lib/libc/stdlib/rand.3 | 13 +++++++------ lib/libc/stdlib/random.3 | 17 ++++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/rand.3 b/lib/libc/stdlib/rand.3 index 3eb1a1d..6805073 100644 --- a/lib/libc/stdlib/rand.3 +++ b/lib/libc/stdlib/rand.3 @@ -55,9 +55,15 @@ .Fn rand_r "unsigned *ctx" .Sh DESCRIPTION .Bf -symbolic +The functions described in this manual page are not cryptographically +secure. +Cryptographic applications should use +.Xr arc4random 3 +instead. +.Ef +.Pp These interfaces are obsoleted by .Xr random 3 . -.Ef .Pp The .Fn rand @@ -88,9 +94,6 @@ The function initializes a seed using the .Xr random 4 random number device which returns good random numbers. -However, the -.Fn rand -function still remains unsuitable for cryptographic use. .Pp The .Fn rand_r @@ -105,8 +108,6 @@ For better generator quality, use .Xr random 3 or .Xr lrand48 3 . -Applications requiring cryptographic quality randomness should use -.Xr arc4random 3 . .Sh SEE ALSO .Xr arc4random 3 , .Xr lrand48 3 , diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index c6502bf..612a37e 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -53,6 +53,14 @@ .Ft char * .Fn setstate "char *state" .Sh DESCRIPTION +.Bf -symbolic +The functions described in this manual page are not cryptographically +secure. +Cryptographic applications should use +.Xr arc4random 3 +instead. +.Ef +.Pp The .Fn random function @@ -98,10 +106,8 @@ as the seed. .Pp The .Fn srandomdev -routine initializes a state array using the -.Xr random 4 -random number device which returns good random numbers, -suitable for cryptographic use. +routine initializes a state array using data from +.Xr random 4 . Note that this particular seeding procedure can generate states which are impossible to reproduce by calling @@ -191,6 +197,3 @@ The historical implementation used to have a very weak seeding; the random sequence did not vary much with the seed. The current implementation employs a better pseudo-random number generator for the initial state calculation. -.Pp -Applications requiring cryptographic quality randomness should use -.Xr arc4random 3 . -- cgit v1.1 From 7c43d2b0905339c3d58017930052930a59197135 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 4 Sep 2012 22:03:16 +0000 Subject: Bump dates. Reminded by: bz@ --- lib/libc/stdlib/rand.3 | 2 +- lib/libc/stdlib/random.3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/rand.3 b/lib/libc/stdlib/rand.3 index 6805073..390a40b 100644 --- a/lib/libc/stdlib/rand.3 +++ b/lib/libc/stdlib/rand.3 @@ -32,7 +32,7 @@ .\" @(#)rand.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd October 6, 2010 +.Dd September 4, 2012 .Dt RAND 3 .Os .Sh NAME diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index 612a37e..e0be8f1 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -28,7 +28,7 @@ .\" @(#)random.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 4, 2012 .Dt RANDOM 3 .Os .Sh NAME -- cgit v1.1 From dfb185f5592710a31d133dc2ce652110587f6c1e Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 5 Sep 2012 11:55:53 +0000 Subject: When WIFCONTINUED was added, the number of "first" macros grew from three to four. MFC after: 1 week --- lib/libc/sys/wait.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2 index e4812fc..71bd529 100644 --- a/lib/libc/sys/wait.2 +++ b/lib/libc/sys/wait.2 @@ -177,7 +177,7 @@ with a value of -1. .Pp The following macros may be used to test the manner of exit of the process. -One of the first three macros will evaluate to a non-zero (true) value: +One of the first four macros will evaluate to a non-zero (true) value: .Bl -tag -width Ds .It Fn WIFCONTINUED status True if the process has not terminated, and -- cgit v1.1 From a78b4512de2417c42cb715e4a9749dac0db57870 Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 5 Sep 2012 21:41:05 +0000 Subject: libc/i386: Do not export .cerror. For some reason, libc exports the symbol .cerror (HIDENAME(cerror)), albeit in the FBSDprivate_1.0 version. It looks like there is no reason for this since it is not used from other libraries. Given that it cannot be accessed from C and its strange calling convention, it is rather unlikely that other things rely on it. Perhaps it is from a time when symbols could not be hidden. Not exporting .cerror causes it to be jumped to directly instead of via the PLT. This change also takes advantage of .cerror's new status by not saving and loading %ebx before jumping to it. (Therefore, .cerror now saves and loads %ebx itself.) Where there was a conditional jump to a jump to .cerror, the conditional jump has been changed to jump to .cerror directly (many modern CPUs don't do static prediction and in any case it is not much of a benefit anyway). This change makes libc.so.7 a few kilobytes smaller. Reviewed by: kib --- lib/libc/i386/SYS.h | 12 ++++++------ lib/libc/i386/Symbol.map | 1 - lib/libc/i386/gen/rfork_thread.S | 3 +-- lib/libc/i386/sys/Ovfork.S | 3 +-- lib/libc/i386/sys/brk.S | 9 ++------- lib/libc/i386/sys/cerror.S | 5 +++-- lib/libc/i386/sys/exect.S | 3 +-- lib/libc/i386/sys/getcontext.S | 5 +---- lib/libc/i386/sys/ptrace.S | 5 +---- lib/libc/i386/sys/sbrk.S | 9 ++------- lib/libc/i386/sys/syscall.S | 5 +---- 11 files changed, 19 insertions(+), 41 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h index a4a147a..355b117 100644 --- a/lib/libc/i386/SYS.h +++ b/lib/libc/i386/SYS.h @@ -36,21 +36,21 @@ #include #include -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(__sys_,x)); \ +#define SYSCALL(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(x); \ .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror) #define RSYSCALL(x) SYSCALL(x); ret; END(__CONCAT(__sys_,x)) -#define PSEUDO(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(__sys_,x)); \ +#define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b; ret; \ + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror); ret; \ END(__CONCAT(__sys_,x)) /* gas messes up offset -- although we don't currently need it, do for BCS */ diff --git a/lib/libc/i386/Symbol.map b/lib/libc/i386/Symbol.map index 8a01802..78be4c4 100644 --- a/lib/libc/i386/Symbol.map +++ b/lib/libc/i386/Symbol.map @@ -63,7 +63,6 @@ FBSDprivate_1.0 { __sys_vfork; _vfork; _end; - .cerror; _brk; .curbrk; .minbrk; diff --git a/lib/libc/i386/gen/rfork_thread.S b/lib/libc/i386/gen/rfork_thread.S index 3333d84..1f8181d 100644 --- a/lib/libc/i386/gen/rfork_thread.S +++ b/lib/libc/i386/gen/rfork_thread.S @@ -113,8 +113,7 @@ ENTRY(rfork_thread) popl %esi movl %ebp, %esp popl %ebp - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) + jmp HIDENAME(cerror) END(rfork_thread) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/i386/sys/Ovfork.S b/lib/libc/i386/sys/Ovfork.S index e3cc45d..3ef7169 100644 --- a/lib/libc/i386/sys/Ovfork.S +++ b/lib/libc/i386/sys/Ovfork.S @@ -50,8 +50,7 @@ ENTRY(__sys_vfork) jmp *%ecx 1: pushl %ecx - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) + jmp HIDENAME(cerror) END(__sys_vfork) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/i386/sys/brk.S b/lib/libc/i386/sys/brk.S index 968e437..8a465d2 100644 --- a/lib/libc/i386/sys/brk.S +++ b/lib/libc/i386/sys/brk.S @@ -58,14 +58,11 @@ ENTRY(brk) ok: mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl 4(%esp),%eax movl %eax,(%edx) movl $0,%eax ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) #else @@ -77,13 +74,11 @@ err: ok: mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl 4(%esp),%eax movl %eax,HIDENAME(curbrk) movl $0,%eax ret -err: - jmp HIDENAME(cerror) #endif END(brk) diff --git a/lib/libc/i386/sys/cerror.S b/lib/libc/i386/sys/cerror.S index 129cc1b..ad3a033 100644 --- a/lib/libc/i386/sys/cerror.S +++ b/lib/libc/i386/sys/cerror.S @@ -48,13 +48,14 @@ __FBSDID("$FreeBSD$"); .globl CNAME(__error) .type CNAME(__error),@function HIDENAME(cerror): - pushl %eax #ifdef PIC - /* The caller must execute the PIC prologue before jumping to cerror. */ + PIC_PROLOGUE + pushl %eax call PIC_PLT(CNAME(__error)) popl %ecx PIC_EPILOGUE #else + pushl %eax call CNAME(__error) popl %ecx #endif diff --git a/lib/libc/i386/sys/exect.S b/lib/libc/i386/sys/exect.S index 3ae87b8..1378b4b 100644 --- a/lib/libc/i386/sys/exect.S +++ b/lib/libc/i386/sys/exect.S @@ -47,8 +47,7 @@ ENTRY(exect) pushl %edx popf KERNCALL - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ + jmp HIDENAME(cerror) /* exect(file, argv, env); */ END(exect) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/i386/sys/getcontext.S b/lib/libc/i386/sys/getcontext.S index c24dbdc..7114689 100644 --- a/lib/libc/i386/sys/getcontext.S +++ b/lib/libc/i386/sys/getcontext.S @@ -42,12 +42,9 @@ ENTRY(__sys_getcontext) movl (%esp),%ecx /* save getcontext return address */ mov $SYS_getcontext,%eax KERNCALL - jb 1f + jb HIDENAME(cerror) addl $4,%esp /* remove stale (setcontext) return address */ jmp *%ecx /* restore return address */ -1: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(__sys_getcontext) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/i386/sys/ptrace.S b/lib/libc/i386/sys/ptrace.S index 6e5e885..e4bdf7c 100644 --- a/lib/libc/i386/sys/ptrace.S +++ b/lib/libc/i386/sys/ptrace.S @@ -50,11 +50,8 @@ ENTRY(ptrace) #endif mov $SYS_ptrace,%eax KERNCALL - jb err + jb HIDENAME(cerror) ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(ptrace) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/i386/sys/sbrk.S b/lib/libc/i386/sys/sbrk.S index 337087a..99fc220 100644 --- a/lib/libc/i386/sys/sbrk.S +++ b/lib/libc/i386/sys/sbrk.S @@ -59,7 +59,7 @@ ENTRY(sbrk) addl %eax,4(%esp) mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) PIC_PROLOGUE movl PIC_GOT(HIDENAME(curbrk)),%edx movl (%edx),%eax @@ -67,9 +67,6 @@ ENTRY(sbrk) PIC_EPILOGUE back: ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) #else /* !PIC */ @@ -80,13 +77,11 @@ err: addl %eax,4(%esp) mov $SYS_break,%eax KERNCALL - jb err + jb HIDENAME(cerror) movl HIDENAME(curbrk),%eax addl %ecx,HIDENAME(curbrk) back: ret -err: - jmp HIDENAME(cerror) #endif /* PIC */ END(sbrk) diff --git a/lib/libc/i386/sys/syscall.S b/lib/libc/i386/sys/syscall.S index e5d6e23..8a08631 100644 --- a/lib/libc/i386/sys/syscall.S +++ b/lib/libc/i386/sys/syscall.S @@ -45,11 +45,8 @@ ENTRY(syscall) KERNCALL push %ecx /* need to push a word to keep stack frame intact upon return; the word must be the return address. */ - jb 1f + jb HIDENAME(cerror) ret -1: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) END(syscall) .section .note.GNU-stack,"",%progbits -- cgit v1.1 From b483b4ba3d82feaef71fa09be9ad987686bd4204 Mon Sep 17 00:00:00 2001 From: trhodes Date: Thu, 6 Sep 2012 20:15:44 +0000 Subject: Avoid segfault if name is invalid. Basically, only check for CTL_USER if the sysctl fails with ENOENT. PR: 169056 Reviewed by: jhb --- lib/libc/gen/sysctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c index fbc2c0c..a5a3d49 100644 --- a/lib/libc/gen/sysctl.c +++ b/lib/libc/gen/sysctl.c @@ -50,8 +50,11 @@ int sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen) { - if (name[0] != CTL_USER) - return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen)); + int retval; + + retval = __sysctl(name, namelen, oldp, oldlenp, newp, newlen); + if (retval != -1 || errno != ENOENT || name[0] != CTL_USER) + return (retval); if (newp != NULL) { errno = EPERM; -- cgit v1.1 From bd7319c0d8e9fd3f2becfb5f5c255627f777b178 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 6 Sep 2012 20:59:49 +0000 Subject: libc/amd64: Do not export .cerror. For some reason, libc exports the symbol .cerror (HIDENAME(cerror)), albeit in the FBSDprivate_1.0 version. It looks like there is no reason for this since it is not used from other libraries. Given that it cannot be accessed from C and its strange calling convention, it is rather unlikely that other things rely on it. Perhaps it is from a time when symbols could not be hidden. Most of the amd64 assembler code jumps to .cerror using the GOT. It can jump to it directly now, as in non-PIC mode. There are also some minor size optimizations to instructions but they yield virtually no benefit in the size of libc.so.7 due to padding. Reviewed by: kib --- lib/libc/amd64/SYS.h | 26 ++++---------------------- lib/libc/amd64/Symbol.map | 1 - lib/libc/amd64/gen/rfork_thread.S | 5 ----- lib/libc/amd64/sys/brk.S | 5 ----- lib/libc/amd64/sys/exect.S | 5 ----- lib/libc/amd64/sys/getcontext.S | 9 +-------- lib/libc/amd64/sys/pipe.S | 9 +-------- lib/libc/amd64/sys/ptrace.S | 9 +-------- lib/libc/amd64/sys/reboot.S | 9 +-------- lib/libc/amd64/sys/sbrk.S | 5 ----- lib/libc/amd64/sys/setlogin.S | 9 +-------- lib/libc/amd64/sys/vfork.S | 5 ----- 12 files changed, 9 insertions(+), 88 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 61d7ab4..a232383 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -36,38 +36,20 @@ #include #include -#ifdef PIC #define RSYSCALL(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(x); \ .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \ + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror); ret; \ END(__CONCAT(__sys_,x)) #define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret ; \ - 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \ + mov __CONCAT($SYS_,x),%eax; KERNCALL; \ + jb HIDENAME(cerror); ret; \ END(__CONCAT(__sys_,x)) -#else -#define RSYSCALL(x) ENTRY(__CONCAT(__sys_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ - .weak CNAME(__CONCAT(_,x)); \ - .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: jmp HIDENAME(cerror); \ - END(__CONCAT(__sys_,x)) - -#define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ - .weak CNAME(__CONCAT(_,x)); \ - .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: jmp HIDENAME(cerror); \ - END(__CONCAT(__sys_,x)) -#endif #define KERNCALL movq %rcx, %r10; syscall diff --git a/lib/libc/amd64/Symbol.map b/lib/libc/amd64/Symbol.map index 9997cc2..bbf6113 100644 --- a/lib/libc/amd64/Symbol.map +++ b/lib/libc/amd64/Symbol.map @@ -66,7 +66,6 @@ FBSDprivate_1.0 { .curbrk; .minbrk; _brk; - .cerror; _end; __sys_vfork; _vfork; diff --git a/lib/libc/amd64/gen/rfork_thread.S b/lib/libc/amd64/gen/rfork_thread.S index 9720e08..5e764db 100644 --- a/lib/libc/amd64/gen/rfork_thread.S +++ b/lib/libc/amd64/gen/rfork_thread.S @@ -93,12 +93,7 @@ ENTRY(rfork_thread) 2: popq %r12 popq %rbx -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)), %rdx - jmp *%rdx -#else jmp HIDENAME(cerror) -#endif END(rfork_thread) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S index 2319417..4048ae6 100644 --- a/lib/libc/amd64/sys/brk.S +++ b/lib/libc/amd64/sys/brk.S @@ -76,12 +76,7 @@ ok: ret err: addq $8, %rsp -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else jmp HIDENAME(cerror) -#endif END(brk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S index 81dc8e5..04a97ed 100644 --- a/lib/libc/amd64/sys/exect.S +++ b/lib/libc/amd64/sys/exect.S @@ -47,12 +47,7 @@ ENTRY(exect) pushq %r8 popfq KERNCALL -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else jmp HIDENAME(cerror) -#endif END(exect) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/getcontext.S b/lib/libc/amd64/sys/getcontext.S index ea29adb..1128796 100644 --- a/lib/libc/amd64/sys/getcontext.S +++ b/lib/libc/amd64/sys/getcontext.S @@ -42,16 +42,9 @@ ENTRY(__sys_getcontext) movq (%rsp),%rsi /* save getcontext return address */ mov $SYS_getcontext,%rax KERNCALL - jb 1f + jb HIDENAME(cerror) addq $8,%rsp /* remove stale (setcontext) return address */ jmp *%rsi /* restore return address */ -1: -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else - jmp HIDENAME(cerror) -#endif END(__sys_getcontext) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/pipe.S b/lib/libc/amd64/sys/pipe.S index 59c1ac1c..8d089db 100644 --- a/lib/libc/amd64/sys/pipe.S +++ b/lib/libc/amd64/sys/pipe.S @@ -45,18 +45,11 @@ __FBSDID("$FreeBSD$"); ENTRY(__sys_pipe) mov $SYS_pipe,%rax KERNCALL - jb 1f + jb HIDENAME(cerror) movl %eax,(%rdi) /* %rdi is preserved by syscall */ movl %edx,4(%rdi) movq $0,%rax ret -1: -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else - jmp HIDENAME(cerror) -#endif END(__sys_pipe) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S index 6235390..9c4628d 100644 --- a/lib/libc/amd64/sys/ptrace.S +++ b/lib/libc/amd64/sys/ptrace.S @@ -48,15 +48,8 @@ ENTRY(ptrace) #endif mov $SYS_ptrace,%eax KERNCALL - jb err + jb HIDENAME(cerror) ret -err: -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else - jmp HIDENAME(cerror) -#endif END(ptrace) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/reboot.S b/lib/libc/amd64/sys/reboot.S index e79ca79..fd04ef4 100644 --- a/lib/libc/amd64/sys/reboot.S +++ b/lib/libc/amd64/sys/reboot.S @@ -45,15 +45,8 @@ __FBSDID("$FreeBSD$"); ENTRY(__sys_reboot) mov $SYS_reboot,%rax KERNCALL - jb 1f + jb HIDENAME(cerror) iretq -1: -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else - jmp HIDENAME(cerror) -#endif END(__sys_reboot) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S index 3e4d8aa..0332aae 100644 --- a/lib/libc/amd64/sys/sbrk.S +++ b/lib/libc/amd64/sys/sbrk.S @@ -79,12 +79,7 @@ back: ret err: addq $8, %rsp -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else jmp HIDENAME(cerror) -#endif END(sbrk) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S index 23692b9..a451491 100644 --- a/lib/libc/amd64/sys/setlogin.S +++ b/lib/libc/amd64/sys/setlogin.S @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); ENTRY(__sys_setlogin) mov $SYS_setlogin,%rax KERNCALL - jb 1f + jb HIDENAME(cerror) #ifdef PIC movq PIC_GOT(CNAME(_logname_valid)),%rdx movl $0,(%rdx) @@ -55,13 +55,6 @@ ENTRY(__sys_setlogin) movl $0,CNAME(_logname_valid)(%rip) #endif ret /* setlogin(name) */ -1: -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else - jmp HIDENAME(cerror) -#endif END(__sys_setlogin) .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S index 555c3ca..2afba58 100644 --- a/lib/libc/amd64/sys/vfork.S +++ b/lib/libc/amd64/sys/vfork.S @@ -50,12 +50,7 @@ ENTRY(__sys_vfork) jmp *%rsi 1: pushq %rsi -#ifdef PIC - movq PIC_GOT(HIDENAME(cerror)),%rdx - jmp *%rdx -#else jmp HIDENAME(cerror) -#endif END(__sys_vfork) .section .note.GNU-stack,"",%progbits -- cgit v1.1 From 33eb85902d21f1188eda1988e6b99dbec047f6db Mon Sep 17 00:00:00 2001 From: des Date: Tue, 11 Sep 2012 12:55:15 +0000 Subject: Add the same warning to rand48(3) as to rand(3) and random(3). MFC after: 3 days --- lib/libc/gen/rand48.3 | 14 ++++++++++---- lib/libc/stdlib/random.3 | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/rand48.3 b/lib/libc/gen/rand48.3 index 8d325a1..c70a832 100644 --- a/lib/libc/gen/rand48.3 +++ b/lib/libc/gen/rand48.3 @@ -12,7 +12,7 @@ .\" @(#)rand48.3 V1.0 MB 8 Oct 1993 .\" $FreeBSD$ .\" -.Dd February 2, 2010 +.Dd September 4, 2012 .Dt RAND48 3 .Os .Sh NAME @@ -49,6 +49,14 @@ .Ft void .Fn lcong48 "unsigned short p[7]" .Sh DESCRIPTION +.Bf -symbolic +The functions described in this manual page are not cryptographically +secure. +Cryptographic applications should use +.Xr arc4random 3 +instead. +.Ef +.Pp The .Fn rand48 family of functions generates pseudo-random numbers using a linear @@ -174,10 +182,8 @@ It is thus not possible to use values greater than 0xffff as the addend. Note that all three methods of seeding the random number generator always also set the multiplicand and addend for any of the six generator calls. -.Pp -For a more powerful random number generator, see -.Xr random 3 . .Sh SEE ALSO +.Xr arc4random 3 , .Xr rand 3 , .Xr random 3 .Sh AUTHORS diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3 index e0be8f1..4817440 100644 --- a/lib/libc/stdlib/random.3 +++ b/lib/libc/stdlib/random.3 @@ -181,7 +181,6 @@ messages are printed on the standard error output. .Xr arc4random 3 , .Xr lrand48 3 , .Xr rand 3 , -.Xr srand 3 , .Xr random 4 .Sh HISTORY These -- cgit v1.1 From 78d32fb722160149b58efdea9e1bf8865786ee9f Mon Sep 17 00:00:00 2001 From: glebius Date: Wed, 12 Sep 2012 09:50:17 +0000 Subject: Describe in detail required conditions for receiving the SCM_CREDS control message and suggest to use LOCAL_CREDS setsockopt() for reliability. --- lib/libc/sys/recv.2 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2 index 66f311f..29ff747 100644 --- a/lib/libc/sys/recv.2 +++ b/lib/libc/sys/recv.2 @@ -28,7 +28,7 @@ .\" @(#)recv.2 8.3 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd December 28, 2006 +.Dd September 12, 2012 .Dt RECV 2 .Os .Sh NAME @@ -252,8 +252,21 @@ struct cmsgcred { }; .Ed .Pp -The kernel will fill in the credential information of the sending process -and deliver it to the receiver. +If a sender supplies ancillary data with enough space for the above struct +tagged as +.Dv SCM_CREDS +control message type to the +.Fn sendmsg +system call, then kernel will fill in the credential information of the +sending process and deliver it to the receiver. +Since receiver usually has no control over a sender, this method of retrieving +credential information isn't reliable. +For reliable retrieval of remote side credentials it is advised to use the +.Dv LOCAL_CREDS +socket option on the receiving socket. +See +.Xr unix 4 +for details. .Pp The .Fa msg_flags @@ -322,7 +335,8 @@ address space. .Xr getsockopt 2 , .Xr read 2 , .Xr select 2 , -.Xr socket 2 +.Xr socket 2 , +.Xr unix 4 .Sh HISTORY The .Fn recv -- cgit v1.1 From 87d02085acfe4d673982fe13086761818cc076a4 Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 12 Sep 2012 17:05:39 +0000 Subject: Avoid mapping ENOENT to ENOTDIR for non-existent path components. The ENOTDIR mapping was introduced in r235266 for kern/128933 based on an interpretation of the somewhat ambiguous language in the POSIX realpath specification. The interpretation is inconsistent with Solaris and Linux, a regression from 9.0, and does not appear to be permitted by the description of ENOTDIR: 20 ENOTDIR Not a directory. A component of the specified pathname existed, but it was not a directory, when a directory was expected. PR: standards/171577 MFC after: 3 days --- lib/libc/stdlib/realpath.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index aded9b2..8fd5457 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -181,8 +181,6 @@ realpath(const char * __restrict path, char * __restrict resolved) return (NULL); } if (lstat(resolved, &sb) != 0) { - if (errno != ENOENT || p != NULL) - errno = ENOTDIR; if (m) free(resolved); return (NULL); -- cgit v1.1 From ed3f0cd13dfb75dc788c906aa7ff44ade3f88e0e Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 12 Sep 2012 17:54:09 +0000 Subject: According to a clarification at http://austingroupbugs.net/view.php?id=503 ptsname may set errno, so avoid saving and restoring errno across the function. PR: standards/171572 --- lib/libc/stdlib/ptsname.3 | 3 ++- lib/libc/stdlib/ptsname.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/ptsname.3 b/lib/libc/stdlib/ptsname.3 index 48da3bd..8e8ec07 100644 --- a/lib/libc/stdlib/ptsname.3 +++ b/lib/libc/stdlib/ptsname.3 @@ -102,7 +102,8 @@ of the slave device on success; otherwise a pointer is returned. .Sh ERRORS The -.Fn grantpt +.Fn grantpt , +.Fn ptsname and .Fn unlockpt functions may fail and set diff --git a/lib/libc/stdlib/ptsname.c b/lib/libc/stdlib/ptsname.c index 40b140d..3e4d4c0 100644 --- a/lib/libc/stdlib/ptsname.c +++ b/lib/libc/stdlib/ptsname.c @@ -77,7 +77,6 @@ ptsname(int fildes) { static char pt_slave[sizeof _PATH_DEV + SPECNAMELEN] = _PATH_DEV; char *ret = NULL; - int sverrno = errno; /* Make sure fildes points to a master device. */ if (__isptmaster(fildes) != 0) @@ -87,7 +86,6 @@ ptsname(int fildes) sizeof pt_slave - (sizeof _PATH_DEV - 1)) != NULL) ret = pt_slave; -done: /* Make sure ptsname() does not overwrite errno. */ - errno = sverrno; +done: return (ret); } -- cgit v1.1 From 8600cbb5b6ebb06db859c9e2c76d07be50b8ff6a Mon Sep 17 00:00:00 2001 From: eadler Date: Fri, 14 Sep 2012 21:28:56 +0000 Subject: Correct double "the the" Approved by: cperciva MFC after: 3 days --- lib/libc/stdio/scanf_l.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/stdio/scanf_l.3 b/lib/libc/stdio/scanf_l.3 index 04ea5d9..405601e 100644 --- a/lib/libc/stdio/scanf_l.3 +++ b/lib/libc/stdio/scanf_l.3 @@ -57,7 +57,7 @@ The above functions scan input according to a specified in the locale .Fa loc . They behave in the same way as the versions without the _l suffix, but use -the specific locale rather than the the global or per-thread locale. +the specific locale rather than the global or per-thread locale. See the specific manual pages for more information. .Sh SEE ALSO .Xr scanf 3 , -- cgit v1.1 From 766649e667cecccb6bb13362bff153ccba07e76c Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 19 Sep 2012 19:21:22 +0000 Subject: strsignal(): Do not append signal numbers to messages for known signals. Messages for known signals looked like "Terminated: 15" instead of "Terminated". --- lib/libc/string/strsignal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c index c51f34d..7bd71fb 100644 --- a/lib/libc/string/strsignal.c +++ b/lib/libc/string/strsignal.c @@ -120,7 +120,6 @@ strsignal(int num) UPREFIX, #endif sizeof(sig_ebuf)); - } signum = num; if (num < 0) @@ -143,6 +142,7 @@ strsignal(int num) break; } *p = '\0'; + } #if defined(NLS) catclose(catd); -- cgit v1.1 From 398bf0a7edf532f65e99b7ef74111493bd290152 Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 19 Sep 2012 19:22:24 +0000 Subject: strsignal(): Reindent. --- lib/libc/string/strsignal.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c index 7bd71fb..8fc1f85 100644 --- a/lib/libc/string/strsignal.c +++ b/lib/libc/string/strsignal.c @@ -121,27 +121,27 @@ strsignal(int num) #endif sizeof(sig_ebuf)); - signum = num; - if (num < 0) - signum = -signum; - - t = tmp; - do { - *t++ = "0123456789"[signum % 10]; - } while (signum /= 10); - if (num < 0) - *t++ = '-'; - - p = (ebuf + n); - *p++ = ':'; - *p++ = ' '; - - for (;;) { - *p++ = *--t; - if (t <= tmp) - break; - } - *p = '\0'; + signum = num; + if (num < 0) + signum = -signum; + + t = tmp; + do { + *t++ = "0123456789"[signum % 10]; + } while (signum /= 10); + if (num < 0) + *t++ = '-'; + + p = (ebuf + n); + *p++ = ':'; + *p++ = ' '; + + for (;;) { + *p++ = *--t; + if (t <= tmp) + break; + } + *p = '\0'; } #if defined(NLS) -- cgit v1.1 From 02ad3abcdd157c2d458fbad597489b46824eea5b Mon Sep 17 00:00:00 2001 From: kevlo Date: Thu, 20 Sep 2012 02:25:18 +0000 Subject: Remove the restrict qualifier to match function prototype. --- lib/libc/sys/recv.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2 index 29ff747..74f275c 100644 --- a/lib/libc/sys/recv.2 +++ b/lib/libc/sys/recv.2 @@ -44,7 +44,7 @@ .Ft ssize_t .Fn recv "int s" "void *buf" "size_t len" "int flags" .Ft ssize_t -.Fn recvfrom "int s" "void * restrict buf" "size_t len" "int flags" "struct sockaddr * restrict from" "socklen_t * restrict fromlen" +.Fn recvfrom "int s" "void *buf" "size_t len" "int flags" "struct sockaddr * restrict from" "socklen_t * restrict fromlen" .Ft ssize_t .Fn recvmsg "int s" "struct msghdr *msg" "int flags" .Sh DESCRIPTION -- cgit v1.1 From c2b29c9319f156dccee19691cf564833580643ae Mon Sep 17 00:00:00 2001 From: pfg Date: Mon, 24 Sep 2012 03:14:17 +0000 Subject: Partial revert of r239963: The following change caused rpc.lockd to exit after startup: ____ libtirpc: be sure to free cl_netid and cl_tp When creating a client with clnt_tli_create, it uses strdup to copy strings for these fields if nconf is passed in. clnt_dg_destroy frees these strings already. Make sure clnt_vc_destroy frees them in the same way. ____ MFC after: 3 days Reported by: David Wolfskill Tested by: David Wolfskill --- lib/libc/rpc/clnt_vc.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index 881f84d..07eff46 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -672,10 +672,6 @@ clnt_vc_destroy(cl) if (ct->ct_addr.buf) free(ct->ct_addr.buf); mem_free(ct, sizeof(struct ct_data)); - if (cl->cl_netid && cl->cl_netid[0]) - mem_free(cl->cl_netid, strlen(cl->cl_netid) +1); - if (cl->cl_tp && cl->cl_tp[0]) - mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); mem_free(cl, sizeof(CLIENT)); mutex_unlock(&clnt_fd_lock); thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -- cgit v1.1 From e4c096aeb4d0889884334130ea1e8ab58ca88a8d Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 27 Sep 2012 17:48:04 +0000 Subject: sigaction(2),sigwait(2),sigwaitinfo(2): Remove [EFAULT] error condition. Passing an invalid pointer results in undefined behaviour. The wrappers in libthr access some of the data pointed to by the arguments in userland, so that an invalid pointer will cause a signal and not an [EFAULT] error return. Furthermore, if the [EFAULT] error occurs when the kernel is writing, it is not a proper error in the sense that the call still commits (changing the signal disposition or accepting the signal). MFC after: 1 week --- lib/libc/sys/sigaction.2 | 9 +-------- lib/libc/sys/sigwait.2 | 5 +---- lib/libc/sys/sigwaitinfo.2 | 5 +---- 3 files changed, 3 insertions(+), 16 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2 index 47b3a72..e161bf2 100644 --- a/lib/libc/sys/sigaction.2 +++ b/lib/libc/sys/sigaction.2 @@ -28,7 +28,7 @@ .\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94 .\" $FreeBSD$ .\" -.Dd April 18, 2010 +.Dd September 27, 2012 .Dt SIGACTION 2 .Os .Sh NAME @@ -586,13 +586,6 @@ system call will fail and no new signal handler will be installed if one of the following occurs: .Bl -tag -width Er -.It Bq Er EFAULT -Either -.Fa act -or -.Fa oact -points to memory that is not a valid part of the process -address space. .It Bq Er EINVAL The .Fa sig diff --git a/lib/libc/sys/sigwait.2 b/lib/libc/sys/sigwait.2 index a9e605c..525bffb 100644 --- a/lib/libc/sys/sigwait.2 +++ b/lib/libc/sys/sigwait.2 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2011 +.Dd September 27, 2012 .Dt SIGWAIT 2 .Os .Sh NAME @@ -107,9 +107,6 @@ The .Fa set argument specifies one or more invalid signal numbers. -.It Bq Er EFAULT -Any arguments point outside the allocated address space or there is a -memory protection fault. .El .Sh SEE ALSO .Xr sigaction 2 , diff --git a/lib/libc/sys/sigwaitinfo.2 b/lib/libc/sys/sigwaitinfo.2 index a83de06..9109759 100644 --- a/lib/libc/sys/sigwaitinfo.2 +++ b/lib/libc/sys/sigwaitinfo.2 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2011 +.Dd September 27, 2012 .Dt SIGTIMEDWAIT 2 .Os .Sh NAME @@ -172,9 +172,6 @@ system calls fail if: .Bl -tag -width Er .It Bq Er EINTR The wait was interrupted by an unblocked, caught signal. -.It Bq Er EFAULT -Any arguments point outside the allocated address space or there is a -memory protection fault. .Pp .El The -- cgit v1.1 From 17db4cd864106dba20aafa24d8c6717ec0aa080e Mon Sep 17 00:00:00 2001 From: pfg Date: Thu, 27 Sep 2012 19:10:25 +0000 Subject: Complete revert of r239963: The attempt to merge changes from the linux libtirpc caused rpc.lockd to exit after startup under unclear conditions. After many hours of selective experiments and inconsistent results the conclusion is that it's better to just revert everything and restart in a future time with a much smaller subset of the changes. ____ MFC after: 3 days Reported by: David Wolfskill Tested by: David Wolfskill --- lib/libc/rpc/auth_unix.c | 10 ++++++---- lib/libc/rpc/authunix_prot.c | 6 +++--- lib/libc/rpc/clnt_perror.c | 19 +++---------------- lib/libc/rpc/rpc_generic.c | 9 ++------- lib/libc/rpc/rpc_soc.3 | 2 +- lib/libc/rpc/rpcb_clnt.c | 7 ------- lib/libc/rpc/svc_auth_unix.c | 2 +- lib/libc/rpc/svc_run.c | 5 +++-- 8 files changed, 19 insertions(+), 41 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 4d7a89b..c0d2548 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -94,10 +94,10 @@ struct audata { AUTH * authunix_create(machname, uid, gid, len, aup_gids) char *machname; - uid_t uid; - gid_t gid; + int uid; + int gid; int len; - gid_t *aup_gids; + int *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -207,7 +207,9 @@ authunix_create_default() abort(); if (ngids > NGRPS) ngids = NGRPS; - auth = authunix_create(machname, uid, gid, ngids, gids); + /* XXX: interface problem; those should all have been unsigned */ + auth = authunix_create(machname, (int)uid, (int)gid, ngids, + (int *)gids); free(gids); return (auth); } diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index dd84810..7699e28 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -60,7 +60,7 @@ xdr_authunix_parms(xdrs, p) XDR *xdrs; struct authunix_parms *p; { - gid_t **paup_gids; + int **paup_gids; assert(xdrs != NULL); assert(p != NULL); @@ -69,8 +69,8 @@ xdr_authunix_parms(xdrs, p) if (xdr_u_long(xdrs, &(p->aup_time)) && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_u_int(xdrs, &(p->aup_uid)) - && xdr_u_int(xdrs, &(p->aup_gid)) + && xdr_int(xdrs, &(p->aup_uid)) + && xdr_int(xdrs, &(p->aup_gid)) && xdr_array(xdrs, (char **) paup_gids, &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { return (TRUE); diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index 87ad3c1..efe9043 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -242,7 +242,7 @@ char * clnt_spcreateerror(s) const char *s; { - char *str, *err; + char *str; size_t len, i; assert(s != NULL); @@ -258,21 +258,8 @@ clnt_spcreateerror(s) switch (rpc_createerr.cf_stat) { case RPC_PMAPFAILURE: (void) strncat(str, " - ", len - 1); - err = clnt_sperrno(rpc_createerr.cf_error.re_status); - if (err) - (void) strncat(str, err+5, len-5); - switch(rpc_createerr.cf_error.re_status) { - case RPC_CANTSEND: - case RPC_CANTRECV: - i = strlen(str); - len -= i; - snprintf(str+i, len, ": errno %d (%s)", - rpc_createerr.cf_error.re_errno, - strerror(rpc_createerr.cf_error.re_errno)); - break; - default: - break; - } + (void) strncat(str, + clnt_sperrno(rpc_createerr.cf_error.re_status), len - 4); break; case RPC_SYSTEMERROR: diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index e592878..ab259d5 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -269,8 +269,7 @@ __rpc_getconfip(nettype) } while ((nconf = getnetconfig(confighandle)) != NULL) { if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { - if (strcmp(nconf->nc_proto, NC_TCP) == 0 && - netid_tcp == NULL) { + if (strcmp(nconf->nc_proto, NC_TCP) == 0) { netid_tcp = strdup(nconf->nc_netid); if (main_thread) netid_tcp_main = netid_tcp; @@ -278,8 +277,7 @@ __rpc_getconfip(nettype) thr_setspecific(tcp_key, (void *) netid_tcp); } else - if (strcmp(nconf->nc_proto, NC_UDP) == 0 && - netid_udp == NULL) { + if (strcmp(nconf->nc_proto, NC_UDP) == 0) { netid_udp = strdup(nconf->nc_netid); if (main_thread) netid_udp_main = netid_udp; @@ -618,9 +616,6 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf) #endif u_int16_t port; - if (nbuf->len <= 0) - return NULL; - switch (af) { case AF_INET: sin = nbuf->buf; diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3 index a049a83..8dedaa8 100644 --- a/lib/libc/rpc/rpc_soc.3 +++ b/lib/libc/rpc/rpc_soc.3 @@ -148,7 +148,7 @@ default authentication used by .Ft "AUTH *" .Xc .It Xo -.Fn authunix_create "char *host" "uid_t uid" "gid_t gid" "int len" "gid_t *aup_gids" +.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids" .Xc .Pp Create and return an diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index b123c32..afef806 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -770,13 +770,6 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) } parms.r_addr = NULL; - parms.r_netid = nconf->nc_netid; - - /* - * According to wire captures, the reference implementation - * (OpenSolaris) sends a blank string here too. - */ - parms.r_owner = ""; /* * Use default total timeout if no timeout is specified. diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index f889d81..4d6f102 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -68,7 +68,7 @@ _svcauth_unix(rqst, msg) struct area { struct authunix_parms area_aup; char area_machname[MAX_MACHINE_NAME+1]; - gid_t area_gids[NGRPS]; + int area_gids[NGRPS]; } *area; u_int auth_len; size_t str_len, gid_len; diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index e6345a6..b4627d6 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -60,13 +60,14 @@ svc_run() fd_set readfds, cleanfds; struct timeval timeout; + timeout.tv_sec = 30; + timeout.tv_usec = 0; + for (;;) { rwlock_rdlock(&svc_fd_lock); readfds = svc_fdset; cleanfds = svc_fdset; rwlock_unlock(&svc_fd_lock); - timeout.tv_sec = 30; - timeout.tv_usec = 0; switch (_select(svc_maxfd+1, &readfds, NULL, NULL, &timeout)) { case -1: FD_ZERO(&readfds); -- cgit v1.1 From f702d078aa3f620abff880ea809f1abe0beef434 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 27 Sep 2012 22:05:54 +0000 Subject: libc/fts: Use O_CLOEXEC for internal file descriptors. Because fts keeps internal file descriptors open across calls, making such descriptors close-on-exec helps not only multi-threaded applications but also single-threaded applications. In particular, this prevents passing a temporary file descriptor for saving the current directory to processes created via find -exec. --- lib/libc/gen/fts-compat.c | 12 +++++++----- lib/libc/gen/fts.c | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 6585416..1be41da 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -220,7 +220,8 @@ __fts_open_44bsd(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) + if (!ISSET(FTS_NOCHDIR) && + (sp->fts_rfd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -349,7 +350,8 @@ __fts_read_44bsd(sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY | O_CLOEXEC, + 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -440,7 +442,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -581,7 +583,7 @@ __fts_children_44bsd(sp, instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) @@ -1180,7 +1182,7 @@ fts_safe_changedir(sp, p, fd, path) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _open(path, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) return (-1); if (_fstat(newfd, &sb)) { ret = -1; diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index afaa057..243320c 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -214,7 +214,8 @@ fts_open(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) + if (!ISSET(FTS_NOCHDIR) && + (sp->fts_rfd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -339,7 +340,8 @@ fts_read(FTS *sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY | O_CLOEXEC, + 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -430,7 +432,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -566,7 +568,7 @@ fts_children(FTS *sp, int instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY | O_CLOEXEC, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) { @@ -1117,7 +1119,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _open(path, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) return (-1); if (_fstat(newfd, &sb)) { ret = -1; -- cgit v1.1 From 26701fe3581a4722deb9c0d0ca58ad7db44f1805 Mon Sep 17 00:00:00 2001 From: des Date: Fri, 28 Sep 2012 13:50:37 +0000 Subject: Slight stylification. --- lib/libc/stdlib/random.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index baae078..6da5419 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -216,10 +216,8 @@ static int rand_deg = DEG_3; static int rand_sep = SEP_3; static uint32_t *end_ptr = &randtbl[DEG_3 + 1]; -static inline uint32_t good_rand(int32_t); - -static inline uint32_t good_rand (x) - int32_t x; +static inline uint32_t +good_rand(int32_t x) { #ifdef USE_WEAK_SEEDING /* @@ -264,8 +262,7 @@ static inline uint32_t good_rand (x) * for default usage relies on values produced by this routine. */ void -srandom(x) - unsigned long x; +srandom(unsigned long x) { int i, lim; @@ -295,7 +292,7 @@ srandom(x) * a fixed seed. */ void -srandomdev() +srandomdev(void) { int fd, done; size_t len; @@ -352,10 +349,7 @@ srandomdev() * complain about mis-alignment, but you should disregard these messages. */ char * -initstate(seed, arg_state, n) - unsigned long seed; /* seed for R.N.G. */ - char *arg_state; /* pointer to state array */ - long n; /* # bytes of state info */ +initstate(unsigned long seed, char *arg_state, long n) { char *ostate = (char *)(&state[-1]); uint32_t *int_arg_state = (uint32_t *)arg_state; @@ -367,7 +361,7 @@ initstate(seed, arg_state, n) if (n < BREAK_0) { (void)fprintf(stderr, "random: not enough state (%ld bytes); ignored.\n", n); - return(0); + return (0); } if (n < BREAK_1) { rand_type = TYPE_0; @@ -397,7 +391,7 @@ initstate(seed, arg_state, n) int_arg_state[0] = rand_type; else int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type; - return(ostate); + return (ostate); } /* @@ -420,8 +414,7 @@ initstate(seed, arg_state, n) * complain about mis-alignment, but you should disregard these messages. */ char * -setstate(arg_state) - char *arg_state; /* pointer to state array */ +setstate(char *arg_state) { uint32_t *new_state = (uint32_t *)arg_state; uint32_t type = new_state[0] % MAX_TYPES; @@ -452,7 +445,7 @@ setstate(arg_state) fptr = &state[(rear + rand_sep) % rand_deg]; } end_ptr = &state[rand_deg]; /* set end_ptr too */ - return(ostate); + return (ostate); } /* @@ -473,7 +466,7 @@ setstate(arg_state) * Returns a 31-bit random number. */ long -random() +random(void) { uint32_t i; uint32_t *f, *r; @@ -498,5 +491,5 @@ random() fptr = f; rptr = r; } - return((long)i); + return ((long)i); } -- cgit v1.1 From fba61ef227067b4f30ac71dee816dd39abee1c8e Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 29 Sep 2012 11:54:34 +0000 Subject: libc: Use O_CLOEXEC for various internal file descriptors. This fixes a race condition where another thread may fork() before CLOEXEC is set, unintentionally passing the descriptor to the child process. This commit only adds O_CLOEXEC flags to open() or openat() calls where no fcntl(fd, F_SETFD, FD_CLOEXEC) follows. The separate fcntl() call still leaves a race window so it should be fixed later. --- lib/libc/gen/arc4random.c | 2 +- lib/libc/gen/getcap.c | 2 +- lib/libc/gen/getcwd.c | 2 +- lib/libc/gen/nlist.c | 2 +- lib/libc/gen/opendir.c | 3 ++- lib/libc/gen/pututxline.c | 6 +++--- lib/libc/gen/readpassphrase.c | 2 +- lib/libc/gen/sem_new.c | 2 +- lib/libc/gen/syslog.c | 3 ++- lib/libc/locale/ldpart.c | 2 +- lib/libc/nls/msgcat.c | 2 +- lib/libc/stdlib/rand.c | 2 +- lib/libc/stdlib/random.c | 2 +- lib/libc/yp/yplib.c | 2 +- 14 files changed, 18 insertions(+), 16 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 46059ab..59e410b 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -153,7 +153,7 @@ arc4_stir(void) if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE) done = 1; if (!done) { - fd = _open(RANDOMDEV, O_RDONLY, 0); + fd = _open(RANDOMDEV, O_RDONLY | O_CLOEXEC, 0); if (fd >= 0) { if (_read(fd, &rdat, KEYSIZE) == KEYSIZE) done = 1; diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index 2700d3d..c321d12 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -264,7 +264,7 @@ getent(char **cap, u_int *len, char **db_array, int fd, const char *name, *cap = cbuf; return (retval); } else { - fd = _open(*db_p, O_RDONLY, 0); + fd = _open(*db_p, O_RDONLY | O_CLOEXEC, 0); if (fd < 0) continue; myfd = 1; diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 40feedf..da76d56 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -142,7 +142,7 @@ getcwd(pt, size) /* Open and stat parent directory. */ fd = _openat(dir != NULL ? _dirfd(dir) : AT_FDCWD, - "..", O_RDONLY); + "..", O_RDONLY | O_CLOEXEC); if (fd == -1) goto err; if (dir) diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 1361af3..159731c 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -66,7 +66,7 @@ nlist(name, list) { int fd, n; - fd = _open(name, O_RDONLY, 0); + fd = _open(name, O_RDONLY | O_CLOEXEC, 0); if (fd < 0) return (-1); n = __fdnlist(fd, list); diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 4366399..2d505fc 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -199,7 +199,8 @@ __opendir_common(int fd, const char *name, int flags) * which has also been read -- see fts.c. */ if (flags & DTF_REWIND) { - if ((fd2 = _open(name, O_RDONLY | O_DIRECTORY)) == -1) { + if ((fd2 = _open(name, O_RDONLY | O_DIRECTORY | + O_CLOEXEC)) == -1) { saved_errno = errno; free(buf); free(dirp); diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c index 98addee..555386c 100644 --- a/lib/libc/gen/pututxline.c +++ b/lib/libc/gen/pututxline.c @@ -47,7 +47,7 @@ futx_open(const char *file) struct stat sb; int fd; - fd = _open(file, O_CREAT|O_RDWR|O_EXLOCK, 0644); + fd = _open(file, O_CREAT|O_RDWR|O_EXLOCK|O_CLOEXEC, 0644); if (fd < 0) return (NULL); @@ -235,7 +235,7 @@ utx_lastlogin_upgrade(void) struct stat sb; int fd; - fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR, 0644); + fd = _open(_PATH_UTX_LASTLOGIN, O_RDWR|O_CLOEXEC, 0644); if (fd < 0) return; @@ -269,7 +269,7 @@ utx_log_add(const struct futx *fu) vec[1].iov_len = l; l = htobe16(l); - fd = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND, 0644); + fd = _open(_PATH_UTX_LOG, O_CREAT|O_WRONLY|O_APPEND|O_CLOEXEC, 0644); if (fd < 0) return (-1); if (_writev(fd, vec, 2) == -1) diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c index d57e703..86c7811 100644 --- a/lib/libc/gen/readpassphrase.c +++ b/lib/libc/gen/readpassphrase.c @@ -68,7 +68,7 @@ restart: * stdin and write to stderr unless a tty is required. */ if ((flags & RPP_STDIN) || - (input = output = _open(_PATH_TTY, O_RDWR)) == -1) { + (input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC)) == -1) { if (flags & RPP_REQUIRE_TTY) { errno = ENOTTY; return(NULL); diff --git a/lib/libc/gen/sem_new.c b/lib/libc/gen/sem_new.c index b748b49..b11d547 100644 --- a/lib/libc/gen/sem_new.c +++ b/lib/libc/gen/sem_new.c @@ -198,7 +198,7 @@ _sem_open(const char *name, int flags, ...) goto error; } - fd = _open(path, flags|O_RDWR, mode); + fd = _open(path, flags|O_RDWR|O_CLOEXEC, mode); if (fd == -1) goto error; if (flock(fd, LOCK_EX) == -1) diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 99308e9..6357761 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -300,7 +300,8 @@ vsyslog(int pri, const char *fmt, va_list ap) * Make sure the error reported is the one from the syslogd failure. */ if (LogStat & LOG_CONS && - (fd = _open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK, 0)) >= 0) { + (fd = _open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK|O_CLOEXEC, 0)) >= + 0) { struct iovec iov[2]; struct iovec *v = iov; diff --git a/lib/libc/locale/ldpart.c b/lib/libc/locale/ldpart.c index ea7b388..ccf5e7f 100644 --- a/lib/libc/locale/ldpart.c +++ b/lib/libc/locale/ldpart.c @@ -87,7 +87,7 @@ __part_load_locale(const char *name, strcat(filename, name); strcat(filename, "/"); strcat(filename, category_filename); - if ((fd = _open(filename, O_RDONLY)) < 0) + if ((fd = _open(filename, O_RDONLY | O_CLOEXEC)) < 0) return (_LDP_ERROR); if (_fstat(fd, &st) != 0) goto bad_locale; diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index 4532e90..44b1440 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -384,7 +384,7 @@ load_msgcat(const char *path, const char *name, const char *lang) } UNLOCK; - if ((fd = _open(path, O_RDONLY)) == -1) { + if ((fd = _open(path, O_RDONLY | O_CLOEXEC)) == -1) { SAVEFAIL(name, lang, errno); NLRETERR(errno); } diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 077c1ba..3835976 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -121,7 +121,7 @@ sranddev() int fd, done; done = 0; - fd = _open("/dev/random", O_RDONLY, 0); + fd = _open("/dev/random", O_RDONLY | O_CLOEXEC, 0); if (fd >= 0) { if (_read(fd, (void *) &next, sizeof(next)) == sizeof(next)) done = 1; diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 6da5419..4a1af54 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -303,7 +303,7 @@ srandomdev(void) len = rand_deg * sizeof state[0]; done = 0; - fd = _open("/dev/random", O_RDONLY, 0); + fd = _open("/dev/random", O_RDONLY | O_CLOEXEC, 0); if (fd >= 0) { if (_read(fd, (void *) state, len) == (ssize_t) len) done = 1; diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 3dfc0aa..1778c6a 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -375,7 +375,7 @@ again: ysd->dom_socket = -1; } snprintf(path, sizeof(path), "%s/%s.%d", BINDINGDIR, dom, 2); - if ((fd = _open(path, O_RDONLY)) == -1) { + if ((fd = _open(path, O_RDONLY | O_CLOEXEC)) == -1) { /* no binding file, YP is dead. */ /* Try to bring it back to life. */ _close(fd); -- cgit v1.1 From 02d21d96e04f7c4cceeb0ecefa0ad9e15f450683 Mon Sep 17 00:00:00 2001 From: eadler Date: Sun, 30 Sep 2012 03:25:04 +0000 Subject: clarify the wording for 'first' and 'last' Approved by: wblock MFC after: 3 days --- lib/libc/string/ffs.3 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/string/ffs.3 b/lib/libc/string/ffs.3 index bf6f5f5..d8e11d8 100644 --- a/lib/libc/string/ffs.3 +++ b/lib/libc/string/ffs.3 @@ -30,7 +30,7 @@ .\" @(#)ffs.3 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd May 3, 2011 +.Dd September 29, 2012 .Dt FFS 3 .Os .Sh NAME @@ -63,8 +63,7 @@ The .Fn ffsl and .Fn ffsll -functions find the first bit set -(beginning with the least significant bit) +functions find the first (least significant) bit set in .Fa value and return the index of that bit. @@ -74,11 +73,11 @@ The .Fn flsl and .Fn flsll -functions find the last bit set in +functions find the last (most significant) bit set in .Fa value and return the index of that bit. .Pp -Bits are numbered starting at 1 (the least significant bit). +Bits are numbered starting at 1, the least significant bit. A return value of zero from any of these functions means that the argument was zero. .Sh SEE ALSO -- cgit v1.1 From 001794b735018a8bbdbac013a520940cd521bb71 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 2 Oct 2012 17:44:08 +0000 Subject: Using putenv() and later direct pointer contents modification it is possibe to craft environment variables with similar names like that: a=1 a=2 ... unsetenv("a") should remove them all to make later getenv("a") impossible. Fix it to do so (this is GNU autoconf test #3 failure too). PR: 172273 MFC after: 1 week --- lib/libc/stdlib/getenv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index b7826d7..37602a9 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -675,11 +675,13 @@ unsetenv(const char *name) /* Deactivate specified variable. */ envNdx = envVarsTotal - 1; - if (__findenv(name, nameLen, &envNdx, true) != NULL) { + /* Remove all occurrences. */ + while (__findenv(name, nameLen, &envNdx, true) != NULL) { envVars[envNdx].active = false; if (envVars[envNdx].putenv) __remove_putenv(envNdx); __rebuild_environ(envActive - 1); + envNdx = envVarsTotal - 1; } return (0); -- cgit v1.1 From 801a570273e78622987dcab8701b018ed637f465 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 2 Oct 2012 19:00:56 +0000 Subject: RPC: Convert all uid and gid variables of the type uid_t and gid_t. This matches what upstream (OpenSolaris) does. Tested by: David Wolfskill Obtained from: Bull GNU/Linux NFSv4 project (libtirpc) MFC after: 3 days --- lib/libc/rpc/auth_unix.c | 10 ++++------ lib/libc/rpc/authunix_prot.c | 6 +++--- lib/libc/rpc/rpc_soc.3 | 2 +- lib/libc/rpc/svc_auth_unix.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index c0d2548..4d7a89b 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -94,10 +94,10 @@ struct audata { AUTH * authunix_create(machname, uid, gid, len, aup_gids) char *machname; - int uid; - int gid; + uid_t uid; + gid_t gid; int len; - int *aup_gids; + gid_t *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -207,9 +207,7 @@ authunix_create_default() abort(); if (ngids > NGRPS) ngids = NGRPS; - /* XXX: interface problem; those should all have been unsigned */ - auth = authunix_create(machname, (int)uid, (int)gid, ngids, - (int *)gids); + auth = authunix_create(machname, uid, gid, ngids, gids); free(gids); return (auth); } diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index 7699e28..dd84810 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -60,7 +60,7 @@ xdr_authunix_parms(xdrs, p) XDR *xdrs; struct authunix_parms *p; { - int **paup_gids; + gid_t **paup_gids; assert(xdrs != NULL); assert(p != NULL); @@ -69,8 +69,8 @@ xdr_authunix_parms(xdrs, p) if (xdr_u_long(xdrs, &(p->aup_time)) && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_int(xdrs, &(p->aup_uid)) - && xdr_int(xdrs, &(p->aup_gid)) + && xdr_u_int(xdrs, &(p->aup_uid)) + && xdr_u_int(xdrs, &(p->aup_gid)) && xdr_array(xdrs, (char **) paup_gids, &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { return (TRUE); diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3 index 8dedaa8..a049a83 100644 --- a/lib/libc/rpc/rpc_soc.3 +++ b/lib/libc/rpc/rpc_soc.3 @@ -148,7 +148,7 @@ default authentication used by .Ft "AUTH *" .Xc .It Xo -.Fn authunix_create "char *host" "int uid" "int gid" "int len" "int *aup_gids" +.Fn authunix_create "char *host" "uid_t uid" "gid_t gid" "int len" "gid_t *aup_gids" .Xc .Pp Create and return an diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index 4d6f102..f889d81 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -68,7 +68,7 @@ _svcauth_unix(rqst, msg) struct area { struct authunix_parms area_aup; char area_machname[MAX_MACHINE_NAME+1]; - int area_gids[NGRPS]; + gid_t area_gids[NGRPS]; } *area; u_int auth_len; size_t str_len, gid_len; -- cgit v1.1 From 7842c9016d1bb554ec3ceff6a37e072c5556531e Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 2 Oct 2012 19:03:21 +0000 Subject: Fix __rpc_getconfip __rpc_getconfip is supposed to return the first netconf entry supporting tcp or udp, respectively. The code will currently return the *last* entry, plus it will leak memory when there is more than one such entry. This change matches the reference (OpenSolaris) implementation. Tested by: David Wolfskill Obtained from: Bull GNU/linux NFSv4 Project (libtirpc) MFC after: 1 week --- lib/libc/rpc/rpc_generic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index ab259d5..0ac4597 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -269,7 +269,8 @@ __rpc_getconfip(nettype) } while ((nconf = getnetconfig(confighandle)) != NULL) { if (strcmp(nconf->nc_protofmly, NC_INET) == 0) { - if (strcmp(nconf->nc_proto, NC_TCP) == 0) { + if (strcmp(nconf->nc_proto, NC_TCP) == 0 && + netid_tcp == NULL) { netid_tcp = strdup(nconf->nc_netid); if (main_thread) netid_tcp_main = netid_tcp; @@ -277,7 +278,8 @@ __rpc_getconfip(nettype) thr_setspecific(tcp_key, (void *) netid_tcp); } else - if (strcmp(nconf->nc_proto, NC_UDP) == 0) { + if (strcmp(nconf->nc_proto, NC_UDP) == 0 && + netid_udp == NULL) { netid_udp = strdup(nconf->nc_netid); if (main_thread) netid_udp_main = netid_udp; -- cgit v1.1 From 4143500b7bd8c48ee7602a796783fc0a455a6d40 Mon Sep 17 00:00:00 2001 From: pfg Date: Tue, 2 Oct 2012 19:10:19 +0000 Subject: libtirpc: be sure to free cl_netid and cl_tp When creating a client with clnt_tli_create, it uses strdup to copy strings for these fields if nconf is passed in. clnt_dg_destroy frees these strings already. Make sure clnt_vc_destroy frees them in the same way. This change matches the reference (OpenSolaris) implementation. Tested by: David Wolfskill Obtained from: Bull GNU/Linux NFSv4 Project (libtirpc) MFC after: 2 weeks --- lib/libc/rpc/clnt_vc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index 07eff46..881f84d 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -672,6 +672,10 @@ clnt_vc_destroy(cl) if (ct->ct_addr.buf) free(ct->ct_addr.buf); mem_free(ct, sizeof(struct ct_data)); + if (cl->cl_netid && cl->cl_netid[0]) + mem_free(cl->cl_netid, strlen(cl->cl_netid) +1); + if (cl->cl_tp && cl->cl_tp[0]) + mem_free(cl->cl_tp, strlen(cl->cl_tp) +1); mem_free(cl, sizeof(CLIENT)); mutex_unlock(&clnt_fd_lock); thr_sigsetmask(SIG_SETMASK, &(mask), NULL); -- cgit v1.1 From d142b7417c2aa871313728dddcbf50ce59f963b0 Mon Sep 17 00:00:00 2001 From: pfg Date: Wed, 3 Oct 2012 03:44:23 +0000 Subject: rpc: convert all uid and gid variables of the type uid_t and gid_t. As part of the previous commit, uses of xdr_int() were replaced with xdr_u_int(). This has undesired effects as the second argument doesn't match exactly uid_t or gid_t. It also breaks assumptions in the size of the provided types. To work around those issues we revert back to the use of xdr_int() but provide proper casting so the behaviour doesn't change. While here fix a style issue in the affected lines. Reported by: bde --- lib/libc/rpc/authunix_prot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index dd84810..437c331 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -67,11 +67,11 @@ xdr_authunix_parms(xdrs, p) paup_gids = &p->aup_gids; - if (xdr_u_long(xdrs, &(p->aup_time)) - && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) - && xdr_u_int(xdrs, &(p->aup_uid)) - && xdr_u_int(xdrs, &(p->aup_gid)) - && xdr_array(xdrs, (char **) paup_gids, + if (xdr_u_long(xdrs, &(p->aup_time)) && + xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) && + xdr_int(xdrs, (int *) &(p->aup_uid)) && + xdr_int(xdrs, (int *) &(p->aup_gid)) && + xdr_array(xdrs, (char **) paup_gids, &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { return (TRUE); } -- cgit v1.1 From cbaa91b07562a45d7a37b3fbaba57b77cbe94468 Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 3 Oct 2012 04:46:58 +0000 Subject: Optimize prev. commit for speed. 1) Don't iterate the loop from the environment array beginning each time, iterate it under the last place we deactivate instead. 2) Call __rebuild_environ() not on each iteration but once, only at the end of whole loop (of course, only in case if something is changed). MFC after: 1 week --- lib/libc/stdlib/getenv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 37602a9..47963d5 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -662,6 +662,7 @@ unsetenv(const char *name) { int envNdx; size_t nameLen; + int newEnvActive; /* Check for malformed name. */ if (name == NULL || (nameLen = __strleneq(name)) == 0) { @@ -674,15 +675,18 @@ unsetenv(const char *name) return (-1); /* Deactivate specified variable. */ - envNdx = envVarsTotal - 1; /* Remove all occurrences. */ + envNdx = envVarsTotal - 1; + newEnvActive = envActive; while (__findenv(name, nameLen, &envNdx, true) != NULL) { envVars[envNdx].active = false; if (envVars[envNdx].putenv) __remove_putenv(envNdx); - __rebuild_environ(envActive - 1); - envNdx = envVarsTotal - 1; + envNdx--; + newEnvActive--; } + if (newEnvActive != envActive) + __rebuild_environ(newEnvActive); return (0); } -- cgit v1.1 From fc02898d2b53483e0c3e7ac6b4d1520e27365095 Mon Sep 17 00:00:00 2001 From: pfg Date: Wed, 3 Oct 2012 20:39:11 +0000 Subject: rpc: convert all uid and gid variables of the type uid_t and gid_t. The previous change (based on Solaris) doesn't work properly either as the casting only has the effect of quieting the compiler. Move back to the previous solution but adjust the sizeof() type in xdr_array(). This should mostly work (by accident). Reported by: bde --- lib/libc/rpc/authunix_prot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index 437c331..36311e8 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -69,10 +69,10 @@ xdr_authunix_parms(xdrs, p) if (xdr_u_long(xdrs, &(p->aup_time)) && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) && - xdr_int(xdrs, (int *) &(p->aup_uid)) && - xdr_int(xdrs, (int *) &(p->aup_gid)) && + xdr_u_int(xdrs, &(p->aup_uid)) && + xdr_u_int(xdrs, &(p->aup_gid)) && xdr_array(xdrs, (char **) paup_gids, - &(p->aup_len), NGRPS, sizeof(int), (xdrproc_t)xdr_int) ) { + &(p->aup_len), NGRPS, sizeof(gid_t), (xdrproc_t)xdr_int) ) { return (TRUE); } return (FALSE); -- cgit v1.1 From 322c7845daaf5e5e0b96fabc9be3aef6573373db Mon Sep 17 00:00:00 2001 From: pfg Date: Thu, 4 Oct 2012 04:15:18 +0000 Subject: rpc: convert all uid and gid variables to u_int. After further discussion, instead of pretending to use uid_t and gid_t as upstream Solaris and linux try to, we are better using u_int, which is in fact what the code can handle and best approaches the range of values used by uid and gid. Discussed with: bde Reviewed by: bde --- lib/libc/rpc/auth_unix.c | 7 ++++--- lib/libc/rpc/authunix_prot.c | 4 ++-- lib/libc/rpc/rpc_soc.3 | 2 +- lib/libc/rpc/svc_auth_unix.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 4d7a89b..5c138d0 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -94,10 +94,10 @@ struct audata { AUTH * authunix_create(machname, uid, gid, len, aup_gids) char *machname; - uid_t uid; - gid_t gid; + u_int uid; + u_int gid; int len; - gid_t *aup_gids; + u_int *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -207,6 +207,7 @@ authunix_create_default() abort(); if (ngids > NGRPS) ngids = NGRPS; + /* XXX: interface problem; we should translate from uid_t and gid_t */ auth = authunix_create(machname, uid, gid, ngids, gids); free(gids); return (auth); diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index 36311e8..f80b176 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -60,7 +60,7 @@ xdr_authunix_parms(xdrs, p) XDR *xdrs; struct authunix_parms *p; { - gid_t **paup_gids; + u_int **paup_gids; assert(xdrs != NULL); assert(p != NULL); @@ -72,7 +72,7 @@ xdr_authunix_parms(xdrs, p) xdr_u_int(xdrs, &(p->aup_uid)) && xdr_u_int(xdrs, &(p->aup_gid)) && xdr_array(xdrs, (char **) paup_gids, - &(p->aup_len), NGRPS, sizeof(gid_t), (xdrproc_t)xdr_int) ) { + &(p->aup_len), NGRPS, sizeof(u_int), (xdrproc_t)xdr_u_int) ) { return (TRUE); } return (FALSE); diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3 index a049a83..1af5728 100644 --- a/lib/libc/rpc/rpc_soc.3 +++ b/lib/libc/rpc/rpc_soc.3 @@ -148,7 +148,7 @@ default authentication used by .Ft "AUTH *" .Xc .It Xo -.Fn authunix_create "char *host" "uid_t uid" "gid_t gid" "int len" "gid_t *aup_gids" +.Fn authunix_create "char *host" "u_int uid" "u_int gid" "int len" "u_int *aup_gids" .Xc .Pp Create and return an diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index f889d81..20d4ecc 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -68,7 +68,7 @@ _svcauth_unix(rqst, msg) struct area { struct authunix_parms area_aup; char area_machname[MAX_MACHINE_NAME+1]; - gid_t area_gids[NGRPS]; + u_int area_gids[NGRPS]; } *area; u_int auth_len; size_t str_len, gid_len; -- cgit v1.1 From 6a02d06d1d81ffda0499310925ef854fd237f382 Mon Sep 17 00:00:00 2001 From: eadler Date: Tue, 9 Oct 2012 14:25:14 +0000 Subject: Remove undefined behavior from sranddev() and srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. Approved by: secteam MFC after: 3 days --- lib/libc/stdlib/rand.c | 3 +-- lib/libc/stdlib/random.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 3835976..7041818 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -130,10 +130,9 @@ sranddev() if (!done) { struct timeval tv; - unsigned long junk; gettimeofday(&tv, NULL); - srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk); + srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec); } } diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 4a1af54..a3c054e 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -312,10 +312,9 @@ srandomdev(void) if (!done) { struct timeval tv; - volatile unsigned long junk; gettimeofday(&tv, NULL); - srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk); + srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec); return; } -- cgit v1.1 From 1ae38f4b7e17061a85721eef3680d89b8ecb16f4 Mon Sep 17 00:00:00 2001 From: stefanf Date: Thu, 11 Oct 2012 07:39:51 +0000 Subject: Apply some style. Checked with md5. --- lib/libc/gen/fstab.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 882c57f..356b871 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -76,7 +76,7 @@ setfstab(const char *file) } const char * -getfstab (void) +getfstab(void) { if (fsp_set) @@ -86,7 +86,7 @@ getfstab (void) } static void -fixfsfile() +fixfsfile(void) { static char buf[sizeof(_PATH_DEV) + MNAMELEN]; struct stat sb; @@ -108,7 +108,7 @@ fixfsfile() } static int -fstabscan() +fstabscan(void) { char *cp, *p; #define MAXLINELENGTH 1024 @@ -119,7 +119,7 @@ fstabscan() for (;;) { if (!(p = fgets(line, sizeof(line), _fs_fp))) - return(0); + return (0); /* OLD_STYLE_FSTAB */ ++LineNo; if (*line == '#' || *line == '\n') @@ -140,7 +140,7 @@ fstabscan() _fs_fstab.fs_freq = atoi(cp); if ((cp = strsep(&p, ":\n")) != NULL) { _fs_fstab.fs_passno = atoi(cp); - return(1); + return (1); } } } @@ -206,7 +206,7 @@ fstabscan() if (typexx) continue; if (cp != NULL) - return(1); + return (1); bad: /* no way to distinguish between EOF and syntax error */ error(EFTYPE); @@ -215,44 +215,45 @@ bad: /* no way to distinguish between EOF and syntax error */ } struct fstab * -getfsent() +getfsent(void) { + if ((!_fs_fp && !setfsent()) || !fstabscan()) - return((struct fstab *)NULL); - return(&_fs_fstab); + return (NULL); + return (&_fs_fstab); } struct fstab * -getfsspec(name) - const char *name; +getfsspec(const char *name) { + if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_spec, name)) - return(&_fs_fstab); - return((struct fstab *)NULL); + return (&_fs_fstab); + return (NULL); } struct fstab * -getfsfile(name) - const char *name; +getfsfile(const char *name) { + if (setfsent()) while (fstabscan()) if (!strcmp(_fs_fstab.fs_file, name)) - return(&_fs_fstab); - return((struct fstab *)NULL); + return (&_fs_fstab); + return (NULL); } -int -setfsent() +int +setfsent(void) { int fd; if (_fs_fp) { rewind(_fs_fp); LineNo = 0; - return(1); + return (1); } if (fsp_set == 0) { if (issetugid()) @@ -268,16 +269,17 @@ setfsent() _fs_fp = fdopen(fd, "r"); if (_fs_fp != NULL) { LineNo = 0; - return(1); + return (1); } error(errno); _close(fd); - return(0); + return (0); } void -endfsent() +endfsent(void) { + if (_fs_fp) { (void)fclose(_fs_fp); _fs_fp = NULL; @@ -287,8 +289,7 @@ endfsent() } static void -error(err) - int err; +error(int err) { char *p; char num[30]; -- cgit v1.1 From 054e35b9ef9943ad6326092f93b873b1495d9540 Mon Sep 17 00:00:00 2001 From: stefanf Date: Thu, 11 Oct 2012 07:54:29 +0000 Subject: Decode the first two fstab fields with strunvis(3). This allows having spaces in devices and mount paths, encoded as \s or \040. PR: bin/117687 Submitted by: Martin Kammerhofer Discussed on: arch --- lib/libc/gen/fstab.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 356b871..1351a27 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "un-namespace.h" static FILE *_fs_fp; @@ -149,11 +150,15 @@ fstabscan(void) /* OLD_STYLE_FSTAB */ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; + if (strunvis(cp, cp) < 0) + goto bad; _fs_fstab.fs_spec = cp; if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; + if (strunvis(cp, cp) < 0) + goto bad; _fs_fstab.fs_file = cp; fixfsfile(); while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') -- cgit v1.1 From 61816f86e167fba086e2c2d4a8dd9a2f318d1b26 Mon Sep 17 00:00:00 2001 From: stefanf Date: Thu, 11 Oct 2012 08:18:28 +0000 Subject: Fix my last commit. Only call strunvis after properly checking the argument is not NULL. --- lib/libc/gen/fstab.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 1351a27..b68db2e 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -150,16 +150,18 @@ fstabscan(void) /* OLD_STYLE_FSTAB */ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - if (strunvis(cp, cp) < 0) - goto bad; _fs_fstab.fs_spec = cp; - if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') + if (_fs_fstab.fs_spec == NULL || *_fs_fstab.fs_spec == '#') continue; + if (strunvis(_fs_fstab.fs_spec, _fs_fstab.fs_spec) < 0) + goto bad; while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - if (strunvis(cp, cp) < 0) - goto bad; _fs_fstab.fs_file = cp; + if (_fs_fstab.fs_file == NULL) + goto bad; + if (strunvis(_fs_fstab.fs_file, _fs_fstab.fs_file) < 0) + goto bad; fixfsfile(); while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; -- cgit v1.1 From 1211b4598c3a9281bc1c7e32d0f2a1d8d3978e81 Mon Sep 17 00:00:00 2001 From: andre Date: Sat, 20 Oct 2012 12:53:14 +0000 Subject: Hide the unfortunate named sysctl kern.ipc.somaxconn from sysctl -a output and replace it with a new visible sysctl kern.ipc.acceptqueue of the same functionality. It specifies the maximum length of the accept queue on a listen socket. The old kern.ipc.somaxconn remains available for reading and writing for compatibility reasons so that existing programs, scripts and configurations continue to work. There no plans to ever remove the orginal and now hidden kern.ipc.somaxconn. --- lib/libc/sys/listen.2 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/listen.2 b/lib/libc/sys/listen.2 index bd6abde..e09d1ca 100644 --- a/lib/libc/sys/listen.2 +++ b/lib/libc/sys/listen.2 @@ -28,7 +28,7 @@ .\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd August 29, 2005 +.Dd October 20, 2012 .Dt LISTEN 2 .Os .Sh NAME @@ -102,15 +102,15 @@ of service attacks are no longer necessary. The .Xr sysctl 3 MIB variable -.Va kern.ipc.somaxconn +.Va kern.ipc.soacceptqueue specifies a hard limit on .Fa backlog ; if a value greater than -.Va kern.ipc.somaxconn +.Va kern.ipc.soacceptqueue or less than zero is specified, .Fa backlog is silently forced to -.Va kern.ipc.somaxconn . +.Va kern.ipc.soacceptqueue . .Sh INTERACTION WITH ACCEPT FILTERS When accept filtering is used on a socket, a second queue will be used to hold sockets that have connected, but have not yet @@ -168,3 +168,17 @@ at run-time, and to use a negative .Fa backlog to request the maximum allowable value, was introduced in .Fx 2.2 . +The +.Va kern.ipc.somaxconn +.Xr sysctl 3 +has been replaced with +.Va kern.ipc.soacceptqueue +in +.Fx 10.0 +to prevent confusion its actual functionality. +The original +.Xr sysctl 3 +.Va kern.ipc.somaxconn +is still available but hidden from a +.Xr sysctl 3 +-a output so that existing applications and scripts continue to work. -- cgit v1.1 From 6062df3e6644d06abdfd53dd83a7a4475ef18264 Mon Sep 17 00:00:00 2001 From: andre Date: Sat, 20 Oct 2012 19:38:22 +0000 Subject: Grammar fixes to r241781. Submitted by: alc --- lib/libc/sys/listen.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/listen.2 b/lib/libc/sys/listen.2 index e09d1ca..ab22fd1 100644 --- a/lib/libc/sys/listen.2 +++ b/lib/libc/sys/listen.2 @@ -175,7 +175,7 @@ has been replaced with .Va kern.ipc.soacceptqueue in .Fx 10.0 -to prevent confusion its actual functionality. +to prevent confusion about its actual functionality. The original .Xr sysctl 3 .Va kern.ipc.somaxconn -- cgit v1.1 From 3f7a414911a892c8c84206394eb643cbde706d20 Mon Sep 17 00:00:00 2001 From: eadler Date: Mon, 22 Oct 2012 03:00:37 +0000 Subject: remove duplicate semicolons where possible. Approved by: cperciva MFC after: 1 week --- lib/libc/net/ip6opt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c index d999fd4..003c625 100644 --- a/lib/libc/net/ip6opt.c +++ b/lib/libc/net/ip6opt.c @@ -461,7 +461,7 @@ inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset) { - int updatelen = offset > 0 ? (1 + ((offset - 1) | 7)) : 0;; + int updatelen = offset > 0 ? (1 + ((offset - 1) | 7)) : 0; if (extbuf) { u_int8_t *padp; -- cgit v1.1 From 7f780401e5c89cc3329023acb7b24d9538e90ed4 Mon Sep 17 00:00:00 2001 From: eadler Date: Mon, 22 Oct 2012 03:37:00 +0000 Subject: Update the kill(2) and killpg(2) man pages to the modern permission checks. Also indicate killpg(2) is POSIX compliant. Reviewed by: jilles Reviewed by: wblock Approved by: cperciva MFC after: 3 days --- lib/libc/compat-43/killpg.2 | 13 +++++-------- lib/libc/sys/kill.2 | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/compat-43/killpg.2 b/lib/libc/compat-43/killpg.2 index b23b773..a1d52a4 100644 --- a/lib/libc/compat-43/killpg.2 +++ b/lib/libc/compat-43/killpg.2 @@ -58,11 +58,9 @@ is 0, .Fn killpg sends the signal to the sending process's process group. .Pp -The sending process and members of the process group must -have the same effective user ID, or -the sender must be the super-user. -As a single special case the continue signal SIGCONT may be sent -to any process with the same session ID as the caller. +The sending process must be able to +.Fn kill +at least one process in the receiving process group. .Sh RETURN VALUES .Rv -std killpg .Sh ERRORS @@ -80,9 +78,8 @@ is not a valid signal number. No process can be found in the process group specified by .Fa pgrp . .It Bq Er EPERM -The sending process is not the super-user and one or more -of the target processes has an effective user ID different from that -of the sending process. +.Fn kill +returns EPERM for all processes in the process group. .El .Sh SEE ALSO .Xr getpgrp 2 , diff --git a/lib/libc/sys/kill.2 b/lib/libc/sys/kill.2 index 0389559..98c3050 100644 --- a/lib/libc/sys/kill.2 +++ b/lib/libc/sys/kill.2 @@ -64,11 +64,19 @@ This can be used to check the validity of For a process to have permission to send a signal to a process designated by .Fa pid , -the real or effective user ID of the receiving process must match -that of the sending process or the user must have appropriate privileges -(such as given by a set-user-ID program or the user is the super-user). +the user must be the super-user, or +the real or saved user ID of the receiving process must match +the real or effective user ID of the sending process. A single exception is the signal SIGCONT, which may always be sent -to any process with the same session ID as the caller. +to any process with the same session ID as the sender. +In addition, if the +.Va security.bsd.conservative_signals +.Xr sysctl +is set to 1, the user is not a super-user, and +the receiver is set-uid, then +only job control and terminal control signals may +be sent (in particular, only SIGKILL, SIGINT, SIGTERM, SIGALRM, +SIGSTOP, SIGTTIN, SIGTTOU, SIGTSTP, SIGHUP, SIGUSR1, SIGUSR2). .Bl -tag -width Ds .It \&If Fa pid No \&is greater than zero : The @@ -124,10 +132,9 @@ is not a valid signal number. No process or process group can be found corresponding to that specified by .Fa pid . .It Bq Er EPERM -The sending process is not the super-user and its effective -user id does not match the effective user-id of the receiving process. -When signaling a process group, this error is returned if any members -of the group could not be signaled. +The sending process does not have permission to send +.Va sig +to the receiving process. .El .Sh SEE ALSO .Xr getpgrp 2 , -- cgit v1.1 From 4be8d9368b2752c5c873a42e74731566ce1d37fe Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 1 Nov 2012 09:38:28 +0000 Subject: fcntl(2): Fix typos in name of constant "F_DUP2FD_CLOEXEC". MFC after: 1 week --- lib/libc/sys/fcntl.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index 63d6510..c174563 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -94,7 +94,7 @@ It is functionally equivalent to .Bd -literal -offset indent dup2(fd, arg) .Ed -.It Dv F_DU2PFD_CLOEXEC +.It Dv F_DUP2FD_CLOEXEC Like .Dv F_DUP2FD , but the @@ -104,7 +104,7 @@ flag associated with the new file descriptor is set. The .Dv F_DUP2FD and -.Dv F_DUP2DF_CLOEXEC +.Dv F_DUP2FD_CLOEXEC constants are not portable, so they should not be used if portability is needed. Use -- cgit v1.1 From 04d3ae223e1eee48cbf974910098d9bd3a9054c2 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 1 Nov 2012 22:47:42 +0000 Subject: fopen(3): Mention that the "x" mode option is from C11. MFC after: 1 week --- lib/libc/stdio/fopen.3 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3 index 64d033e..08438e7 100644 --- a/lib/libc/stdio/fopen.3 +++ b/lib/libc/stdio/fopen.3 @@ -267,7 +267,11 @@ and .Fn freopen functions conform to -.St -isoC . +.St -isoC , +with the exception of the +.Dq Li x +mode option which conforms to +.St -isoC-2011 . The .Fn fdopen function -- cgit v1.1 From 7d0528e7e8b8b3e83cd5bca8737945d73916a5f8 Mon Sep 17 00:00:00 2001 From: tuexen Date: Sat, 3 Nov 2012 13:22:25 +0000 Subject: Fix errno in a couple of error cases. MFC after: 3 days --- lib/libc/net/sctp_sys_calls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 3785a04..1e06f44 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -449,6 +449,7 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) opt_len = (socklen_t) ((size_t)asoc + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { + errno = ENOMEM; return (-1); } addrs->sget_assoc_id = id; @@ -777,6 +778,7 @@ sctp_sendx(int sd, const void *msg, size_t msg_len, } buf = malloc(len); if (buf == NULL) { + errno = ENOMEM; return (-1); } aa = (int *)buf; @@ -1052,7 +1054,7 @@ sctp_sendv(int sd, CMSG_SPACE(sizeof(struct sctp_authinfo)) + (size_t)addrcnt * CMSG_SPACE(sizeof(struct in6_addr))); if (cmsgbuf == NULL) { - errno = ENOBUFS; + errno = ENOMEM; return (-1); } msg.msg_control = cmsgbuf; -- cgit v1.1