CVS commit: src/lib/libc/gen
Module Name:src Committed By: dholland Date: Sat Aug 7 03:17:23 UTC 2021 Modified Files: src/lib/libc/gen: signal.3 Log Message: typo To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libc/gen/signal.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/signal.3 diff -u src/lib/libc/gen/signal.3:1.28 src/lib/libc/gen/signal.3:1.29 --- src/lib/libc/gen/signal.3:1.28 Wed Dec 6 16:38:22 2017 +++ src/lib/libc/gen/signal.3 Sat Aug 7 03:17:23 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: signal.3,v 1.28 2017/12/06 16:38:22 dholland Exp $ +.\" $NetBSD: signal.3,v 1.29 2021/08/07 03:17:23 dholland Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -148,7 +148,7 @@ function; ignored signals remain ignored. .Pp Only functions that are async-signal-safe can safely be used in signal -handlers, see +handlers; see .Xr sigaction 2 for a complete list. .Sh RETURN VALUES
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Sun Jul 11 16:30:41 UTC 2021 Modified Files: src/lib/libc/gen: initdir.c Log Message: Make sure dd_size is init'd, even when nothing has been read (so it will be 0). Reported on tech-userlevel by Mouse 20210711T044753+ To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gen/initdir.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/initdir.c diff -u src/lib/libc/gen/initdir.c:1.4 src/lib/libc/gen/initdir.c:1.5 --- src/lib/libc/gen/initdir.c:1.4 Fri Dec 16 04:45:04 2016 +++ src/lib/libc/gen/initdir.c Sun Jul 11 16:30:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: initdir.c,v 1.4 2016/12/16 04:45:04 mrg Exp $ */ +/* $NetBSD: initdir.c,v 1.5 2021/07/11 16:30:41 kre Exp $ */ /* * Copyright (c) 1983, 1993 @@ -31,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: initdir.c,v 1.4 2016/12/16 04:45:04 mrg Exp $"); +__RCSID("$NetBSD: initdir.c,v 1.5 2021/07/11 16:30:41 kre Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -242,6 +242,7 @@ retry: dirp->dd_size = ddptr - dirp->dd_buf; } else { dirp->dd_len = incr; + dirp->dd_size = 0; dirp->dd_buf = malloc((size_t)dirp->dd_len); if (dirp->dd_buf == NULL) return errno;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Fri Jun 18 10:57:14 UTC 2021 Modified Files: src/lib/libc/gen: vis.c Log Message: PR/56260: Alex Richardson: Out-of-bounds stack read in lib/libc/gen/vis.c Also sync with other FreeBSD changes. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/lib/libc/gen/vis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.c diff -u src/lib/libc/gen/vis.c:1.74 src/lib/libc/gen/vis.c:1.75 --- src/lib/libc/gen/vis.c:1.74 Mon Nov 27 11:37:21 2017 +++ src/lib/libc/gen/vis.c Fri Jun 18 06:57:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $ */ +/* $NetBSD: vis.c,v 1.75 2021/06/18 10:57:14 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $"); +__RCSID("$NetBSD: vis.c,v 1.75 2021/06/18 10:57:14 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef __FBSDID __FBSDID("$FreeBSD$"); @@ -353,12 +353,15 @@ makeextralist(int flags, const char *src wchar_t *dst, *d; size_t len; const wchar_t *s; + mbstate_t mbstate; len = strlen(src); if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL) return NULL; - if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) { + memset(, 0, sizeof(mbstate)); + if ((flags & VIS_NOLOCALE) + || mbsrtowcs(dst, , len, ) == (size_t)-1) { size_t i; for (i = 0; i < len; i++) dst[i] = (wchar_t)(u_char)src[i]; @@ -401,6 +404,7 @@ istrsenvisx(char **mbdstp, size_t *dlen, int clen = 0, cerr, error = -1, i, shft; char *mbdst, *mdst; ssize_t mbslength, maxolen; + mbstate_t mbstate; _DIAGASSERT(mbdstp != NULL); _DIAGASSERT(mbsrc != NULL || mblength == 0); @@ -458,10 +462,12 @@ istrsenvisx(char **mbdstp, size_t *dlen, * stop at NULs because we may be processing a block of data * that includes NULs. */ + memset(, 0, sizeof(mbstate)); while (mbslength > 0) { /* Convert one multibyte character to wchar_t. */ if (!cerr) - clen = mbtowc(src, mbsrc, MB_LEN_MAX); + clen = mbrtowc(src, mbsrc, MIN(mbslength, MB_LEN_MAX), + ); if (cerr || clen < 0) { /* Conversion error, process as a byte instead. */ *src = (wint_t)(u_char)*mbsrc; @@ -534,9 +540,10 @@ istrsenvisx(char **mbdstp, size_t *dlen, len = wcslen(start); maxolen = dlen ? *dlen : (wcslen(start) * MB_LEN_MAX + 1); olen = 0; + memset(, 0, sizeof(mbstate)); for (dst = start; len > 0; len--) { if (!cerr) - clen = wctomb(mbdst, *dst); + clen = wcrtomb(mbdst, *dst, ); if (cerr || clen < 0) { /* * Conversion error, process as a byte(s) instead.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: riastradh Date: Mon May 24 23:59:59 UTC 2021 Modified Files: src/lib/libc/gen: setjmp.3 Log Message: Clarify what happens when you longjmp(..., 0). Derived from C99 7.13.2.1 `The longjmp function'. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/setjmp.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/setjmp.3 diff -u src/lib/libc/gen/setjmp.3:1.17 src/lib/libc/gen/setjmp.3:1.18 --- src/lib/libc/gen/setjmp.3:1.17 Sat May 31 16:15:07 2008 +++ src/lib/libc/gen/setjmp.3 Mon May 24 23:59:59 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: setjmp.3,v 1.17 2008/05/31 16:15:07 enami Exp $ +.\" $NetBSD: setjmp.3,v 1.18 2021/05/24 23:59:59 riastradh Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -85,6 +85,15 @@ invocation of the call had just returned the value specified by .Fa val , instead of 0. +The +.Fn longjmp +functions cannot cause +.Fn setjmp +to return 0; if +.Fa val +is 0, +.Fn setjmp +returns 1 instead. .Pp Pairs of calls may be intermixed, i.e., both .Fn sigsetjmp
CVS commit: src/lib/libc/gen
Module Name:src Committed By: simonb Date: Mon May 3 08:30:30 UTC 2021 Modified Files: src/lib/libc/gen: Makefile.inc Log Message: Whitespace police. To generate a diff of this commit: cvs rdiff -u -r1.212 -r1.213 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.212 src/lib/libc/gen/Makefile.inc:1.213 --- src/lib/libc/gen/Makefile.inc:1.212 Tue Apr 20 21:42:32 2021 +++ src/lib/libc/gen/Makefile.inc Mon May 3 08:30:30 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.212 2021/04/20 21:42:32 christos Exp $ +# $NetBSD: Makefile.inc,v 1.213 2021/05/03 08:30:30 simonb Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -102,7 +102,7 @@ MLINKS+=endutxent.3 getutxent.3 endutxen MLINKS+=endutent.3 getutent.3 endutent.3 getutline.3 endutent.3 pututline.3 \ endutent.3 setutent.3 MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \ -err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ + err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ err.3 vwarnc.3 MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 execlpe.3 \ exec.3 execv.3 exec.3 execvp.3 exec.3 execvpe.3 exec.3 exect.3 @@ -113,7 +113,7 @@ MLINKS+=extattr_namespace_to_string.3 ex extattr_copy_file.3 fcpxattr.3 \ extattr_copy_file.3 lcpxattr.3 MLINKS+=fpgetmask.3 fpgetround.3 fpgetmask.3 fpgetsticky.3 \ - fpgetmask.3 fpsetmask.3 fpgetmask.3 fpsetround.3 \ + fpgetmask.3 fpsetmask.3 fpgetmask.3 fpsetround.3 \ fpgetmask.3 fpsetsticky.3 fpgetmask.3 fpgetprec.3 \ fpgetmask.3 fpsetprec.3 MLINKS+=fts.3 fts_open.3 fts.3 fts_read.3 fts.3 fts_children.3 \
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rillig Date: Tue Mar 30 15:31:51 UTC 2021 Modified Files: src/lib/libc/gen: sysctl.c Log Message: libc/gen: fix hack for previously unsupported lint initializers Supported since init.c 1.182 from 2021-03-30. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/lib/libc/gen/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/sysctl.c diff -u src/lib/libc/gen/sysctl.c:1.37 src/lib/libc/gen/sysctl.c:1.38 --- src/lib/libc/gen/sysctl.c:1.37 Wed May 16 20:21:39 2018 +++ src/lib/libc/gen/sysctl.c Tue Mar 30 15:31:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.c,v 1.37 2018/05/16 20:21:39 joerg Exp $ */ +/* $NetBSD: sysctl.c,v 1.38 2021/03/30 15:31:51 rillig Exp $ */ /*- * Copyright (c) 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94"; #else -__RCSID("$NetBSD: sysctl.c,v 1.37 2018/05/16 20:21:39 joerg Exp $"); +__RCSID("$NetBSD: sysctl.c,v 1.38 2021/03/30 15:31:51 rillig Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -120,12 +120,6 @@ user_sysctl(const int *name, unsigned in * the nodes under the "user" node */ static const struct sysctlnode sysctl_usermib[] = { -#if defined(lint) - /* - * lint doesn't like my initializers - */ - 0 -#else /* !lint */ { .sysctl_flags = SYSCTL_VERSION|CTLFLAG_PERMANENT| CTLTYPE_STRING, @@ -239,7 +233,6 @@ user_sysctl(const int *name, unsigned in _INT("atexit_max", USER_ATEXIT_MAX, -1, "The maximum number of functions that may be registered " "with atexit(3)"), -#endif /* !lint */ }; #undef _INT
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Fri Feb 26 06:39:14 UTC 2021 Modified Files: src/lib/libc/gen: endutent.3 Log Message: Fix xref, add missing word. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/endutent.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/endutent.3 diff -u src/lib/libc/gen/endutent.3:1.1 src/lib/libc/gen/endutent.3:1.2 --- src/lib/libc/gen/endutent.3:1.1 Fri Feb 26 03:05:01 2021 +++ src/lib/libc/gen/endutent.3 Fri Feb 26 06:39:14 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: endutent.3,v 1.1 2021/02/26 03:05:01 christos Exp $ +.\" $NetBSD: endutent.3,v 1.2 2021/02/26 06:39:14 wiz Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -58,7 +58,7 @@ user accounting database. .Pp These interfaces are only provided for compatibility purpuses and have been superseeded by -.Xr endutent 3 , +.Xr endutxent 3 , .Xr utmpx 5 . .Pp .Fn getutent @@ -88,7 +88,6 @@ the same user if it exists. The .Nm utmp structure has the following definition: -.Pp .Bd -literal struct utmp { char ut_line[UT_LINESIZE];/* tty name */ @@ -119,5 +118,5 @@ The .Fn getutline , .Fn pututline , .Fn setutent -all conform to +functions all conform to .St -xpg4.2 .
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Fri Feb 26 04:28:15 UTC 2021 Modified Files: src/lib/libc/gen: Makefile.inc Log Message: Add missing endutent.3 to MAN. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.208 src/lib/libc/gen/Makefile.inc:1.209 --- src/lib/libc/gen/Makefile.inc:1.208 Fri Feb 26 03:19:34 2021 +++ src/lib/libc/gen/Makefile.inc Fri Feb 26 04:28:14 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.208 2021/02/26 03:19:34 christos Exp $ +# $NetBSD: Makefile.inc,v 1.209 2021/02/26 04:28:14 rin Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -56,7 +56,8 @@ COPTS.syslog.c = -Wno-format-nonliteral MAN+= alarm.3 arc4random.3 basename.3 bsd_signal.3 bswap.3 \ clock.3 closefrom.3 confstr.3 \ cpuset.3 ctermid.3 ctype.3 daemon.3 devname.3 directory.3 dirname.3 \ - endutxent.3 err.3 exec.3 extattr_copy_file.3 extattr_namespace_to_string.3 \ + endutent.3 endutxent.3 err.3 exec.3 extattr_copy_file.3 \ + extattr_namespace_to_string.3 \ fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 fpgetmask.3 \ ftok.3 fts.3 ftw.3 \ getbsize.3 cgetcap.3 getcwd.3 getdevmajor.3 \
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Fri Feb 26 03:19:34 UTC 2021 Modified Files: src/lib/libc/gen: Makefile.inc Log Message: put back line accidentally removed. To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.207 src/lib/libc/gen/Makefile.inc:1.208 --- src/lib/libc/gen/Makefile.inc:1.207 Thu Feb 25 22:05:01 2021 +++ src/lib/libc/gen/Makefile.inc Thu Feb 25 22:19:34 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.207 2021/02/26 03:05:01 christos Exp $ +# $NetBSD: Makefile.inc,v 1.208 2021/02/26 03:19:34 christos Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -145,6 +145,7 @@ MLINKS+=getpwent.3 endpwent.3 getpwent.3 MLINKS+=getpwent.3 getpwnam_r.3 getpwent.3 getpwuid_r.3 getpwent.3 getpwent_r.3 # getpwent.3 setpwfile.3 - deprecated MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ + getttyent.3 setttyent.3 getttyent.3 setttyentpath.3 MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 MLINKS+=glob.3 globfree.3 MLINKS+=glob.3 glob_pattern_p.3
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Fri Feb 26 03:05:01 UTC 2021 Modified Files: src/lib/libc/gen: Makefile.inc Added Files: src/lib/libc/gen: endutent.3 Log Message: PR/56012: Kouichi Hashikawa: getutent(3) man page is missing To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/lib/libc/gen/Makefile.inc cvs rdiff -u -r0 -r1.1 src/lib/libc/gen/endutent.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.206 src/lib/libc/gen/Makefile.inc:1.207 --- src/lib/libc/gen/Makefile.inc:1.206 Tue Sep 22 17:37:47 2020 +++ src/lib/libc/gen/Makefile.inc Thu Feb 25 22:05:01 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.206 2020/09/22 21:37:47 nia Exp $ +# $NetBSD: Makefile.inc,v 1.207 2021/02/26 03:05:01 christos Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -98,6 +98,8 @@ MLINKS+=directory.3 closedir.3 directory MLINKS+=endutxent.3 getutxent.3 endutxent.3 getutxid.3 \ endutxent.3 getutxline.3 endutxent.3 pututxline.3 \ endutxent.3 setutxent.3 +MLINKS+=endutent.3 getutent.3 endutent.3 getutline.3 endutent.3 pututline.3 \ + endutent.3 setutent.3 MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \ err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ err.3 vwarnc.3 @@ -143,7 +145,6 @@ MLINKS+=getpwent.3 endpwent.3 getpwent.3 MLINKS+=getpwent.3 getpwnam_r.3 getpwent.3 getpwuid_r.3 getpwent.3 getpwent_r.3 # getpwent.3 setpwfile.3 - deprecated MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ - getttyent.3 setttyent.3 getttyent.3 setttyentpath.3 MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 MLINKS+=glob.3 globfree.3 MLINKS+=glob.3 glob_pattern_p.3 Added files: Index: src/lib/libc/gen/endutent.3 diff -u /dev/null src/lib/libc/gen/endutent.3:1.1 --- /dev/null Thu Feb 25 22:05:01 2021 +++ src/lib/libc/gen/endutent.3 Thu Feb 25 22:05:01 2021 @@ -0,0 +1,123 @@ +.\" $NetBSD: endutent.3,v 1.1 2021/02/26 03:05:01 christos Exp $ +.\" +.\" Copyright (c) 2002 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Thomas Klausner. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd February 25, 2021 +.Dt ENDUTENT 3 +.Os +.Sh NAME +.Nm endutent , +.Nm getutent , +.Nm getutline , +.Nm pututline , +.Nm setutent +.Nd user accounting database functions +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In utmp.h +.Ft void +.Fn endutent void +.Ft struct utmp * +.Fn getutent void +.Ft struct utmpx * +.Fn getutline "const struct utmp *" +.Ft struct utmp * +.Fn pututline "const struct utmp *" +.Ft void +.Fn setutent void +.Sh DESCRIPTION +These functions provide access to the +.Xr utmp 5 +user accounting database. +.Pp +These interfaces are only provided for compatibility purpuses and +have been superseeded by +.Xr endutent 3 , +.Xr utmpx 5 . +.Pp +.Fn getutent +reads the next entry from the database; +if the database was not yet open, it also opens it. +.Fn setutent +resets the database, so that the next +.Fn getutent +call will get the first entry. +.Fn endutent +closes the database. +.Pp +.Fn getutline +returns the next +entry which has the same name as specified in the +.Va ut_line +field, or +.Dv NULL +if no match is found. +.Pp +.Fn pututline +adds the argument +.Xr utmp 5 +entry line to the accounting database, replacing a previous entry for +the same user if it exists. +.Ss The utmp structure +The +.Nm utmp +structure has the following
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rillig Date: Sun Feb 21 16:33:23 UTC 2021 Modified Files: src/lib/libc/gen: isascii.3 Log Message: isascii.3: fix typo To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/lib/libc/gen/isascii.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/isascii.3 diff -u src/lib/libc/gen/isascii.3:1.18 src/lib/libc/gen/isascii.3:1.19 --- src/lib/libc/gen/isascii.3:1.18 Fri Apr 30 04:46:18 2010 +++ src/lib/libc/gen/isascii.3 Sun Feb 21 16:33:22 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: isascii.3,v 1.18 2010/04/30 04:46:18 jruoho Exp $ +.\" $NetBSD: isascii.3,v 1.19 2021/02/21 16:33:22 rillig Exp $ .\" .\" Copyright (c) 1989, 1991 The Regents of the University of California. .\" All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)isascii.3 5.1 (Berkeley) 5/2/91 .\" -.Dd April 30, 2010 +.Dd February 21, 2021 .Dt ISASCII 3 .Os .Sh NAME @@ -51,7 +51,7 @@ range from 0 to 127, inclusive. .Pp The .Fn isascii -is defined on all integer values. +function is defined on all integer values. .Sh SEE ALSO .Xr ctype 3 , .Xr isalnum 3 ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: dholland Date: Wed Feb 17 23:51:04 UTC 2021 Modified Files: src/lib/libc/gen: directory.3 Log Message: Document that rewinddir(3) might either reopen or just lseek the dir. (Currently it depends on the underlying directory, but documenting the exact details seems inadvisable.) Also, Someone(TM) should check if POSIX permits this or if we ought to improve the implementation. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/lib/libc/gen/directory.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/directory.3 diff -u src/lib/libc/gen/directory.3:1.42 src/lib/libc/gen/directory.3:1.43 --- src/lib/libc/gen/directory.3:1.42 Wed Feb 17 23:39:46 2021 +++ src/lib/libc/gen/directory.3 Wed Feb 17 23:51:04 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: directory.3,v 1.42 2021/02/17 23:39:46 dholland Exp $ +.\" $NetBSD: directory.3,v 1.43 2021/02/17 23:51:04 dholland Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)directory.3 8.1 (Berkeley) 6/4/93 .\" -.Dd January 22, 2016 +.Dd February 17, 2021 .Dt DIRECTORY 3 .Os .Sh NAME @@ -225,6 +225,15 @@ It also causes the directory stream to r current state of the corresponding directory, as if a call to .Fn opendir was made. +It is not specified whether this refers to the ``corresponding directory'' +by name or by underlying object. +(These can differ if +.Xr rename 2 +has been used.) +.\" Note: currently the underlying fd is reopened if and only if +.\" __DTF_READALL is in effect, which is true for union mounts and +.\" nfs; documenting that exactly seems inadvisable since it might +.\" change. -- dholland 20210217 .Pp If .Fa dirp
CVS commit: src/lib/libc/gen
Module Name:src Committed By: dholland Date: Wed Feb 17 23:39:46 UTC 2021 Modified Files: src/lib/libc/gen: directory.3 Log Message: Fix some typos/malapropisms in directory(3). To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/lib/libc/gen/directory.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/directory.3 diff -u src/lib/libc/gen/directory.3:1.41 src/lib/libc/gen/directory.3:1.42 --- src/lib/libc/gen/directory.3:1.41 Mon Jul 3 21:32:49 2017 +++ src/lib/libc/gen/directory.3 Wed Feb 17 23:39:46 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: directory.3,v 1.41 2017/07/03 21:32:49 wiz Exp $ +.\" $NetBSD: directory.3,v 1.42 2021/02/17 23:39:46 dholland Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -224,7 +224,7 @@ stream to the beginning of the directory It also causes the directory stream to refer to the current state of the corresponding directory, as if a call to .Fn opendir -would have been made. +was made. .Pp If .Fa dirp @@ -281,7 +281,7 @@ return (NOT_FOUND); .Sh COMPATIBILITY The described directory operations have traditionally been problematic in terms of portability. -A good example is the semantics around +A good example is the semantics of .Sq \&. (dot) and .Sq \&.. @@ -313,7 +313,7 @@ When a file descriptor is used to implem function behaves as if the .Dv FD_CLOEXEC had been set for the file descriptor. -In another words, it is mandatory that +In other words, it is mandatory that .Fn closedir deallocates the file descriptor. .It @@ -344,9 +344,9 @@ occurred between the calls to .Fn telldir and .Fn seekdir , -any subsequent call to +the results of any subsequent call to .Fn readdir -is unspecified, possibly resulting in undefined behavior. +are unspecified, possibly resulting in undefined behavior. .It After a call to .Xr fork 2 ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Thu Aug 20 22:56:56 UTC 2020 Modified Files: src/lib/libc/gen: signalname.3 signalnumber.c Log Message: When not compiling -DSMALL permit use of names RTMIN[+n] and RTMAX[-n] (where n is a decimal integer in the range [0 .. SIGRTMAX-SIGRTMIN]. As usual a leading "sig" is ignored and the strings are case independent. Some implementations do not name the real time signals, and using labels like RTMIN+3 can be the only way they can be manipulated, so allow that technique (we still return the RTnn names on the inverse translation though). Because this is used by both kill(1) and sh(1) the kill and trap commands both gain access to the new notation (when !SMALL). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/signalname.3 \ src/lib/libc/gen/signalnumber.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/signalname.3 diff -u src/lib/libc/gen/signalname.3:1.2 src/lib/libc/gen/signalname.3:1.3 --- src/lib/libc/gen/signalname.3:1.2 Sun May 14 12:35:46 2017 +++ src/lib/libc/gen/signalname.3 Thu Aug 20 22:56:56 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: signalname.3,v 1.2 2017/05/14 12:35:46 wiz Exp $ +.\" $NetBSD: signalname.3,v 1.3 2020/08/20 22:56:56 kre Exp $ .\" .\" Available to all and sundry, without restriction on use, or other .\" limitations, and without fee. Also without any warranty of fitness @@ -76,6 +76,17 @@ prefix in .Fa name is ignored. .Pp +This implementation also accepts +.Dv rtmax Ns \&[\-n] +and +.Dv rtmin Ns \&[+n] +.Po +where the optional +.Ar n +is a decimal integer between 0 and SIGRTMAX\-SIGRTMIN +.Pc +to refer to the real time signals. +.Pp The .Fn signalnumber function returns the signal number, @@ -93,7 +104,8 @@ signal number. .Pp The .Fn signalnext -function returns minus one (\-1) on error, if the given signal +function returns minus one (\-1) on error, +that is, if the given signal .Fa sig is neither a valid signal number nor zero. It returns zero when the input signal number, Index: src/lib/libc/gen/signalnumber.c diff -u src/lib/libc/gen/signalnumber.c:1.2 src/lib/libc/gen/signalnumber.c:1.3 --- src/lib/libc/gen/signalnumber.c:1.2 Thu Jan 4 20:57:29 2018 +++ src/lib/libc/gen/signalnumber.c Thu Aug 20 22:56:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: signalnumber.c,v 1.2 2018/01/04 20:57:29 kamil Exp $ */ +/* $NetBSD: signalnumber.c,v 1.3 2020/08/20 22:56:56 kre Exp $ */ /* * Software available to all and sundry without limitations @@ -20,7 +20,9 @@ #include "namespace.h" #include +#include #include +#include /* * signalnumber() @@ -42,6 +44,10 @@ int signalnumber(const char *name) { int i; +#ifndef SMALL + long offs; + char *ep; +#endif if (strncasecmp(name, "sig", 3) == 0) name += 3; @@ -50,5 +56,36 @@ signalnumber(const char *name) if (sys_signame[i] != NULL && strcasecmp(name, sys_signame[i]) == 0) return i; + +#ifndef SMALL + if (strncasecmp(name, "rtm", 3) == 0) { + name += 3; + if (strncasecmp(name, "ax", 2) == 0) + i = SIGRTMAX; + else if (strncasecmp(name, "in", 2) == 0) + i = SIGRTMIN; + else + return 0; + name += 2; + if (name[0] == '\0') + return i; + if (i == SIGRTMAX && name[0] != '-') + return 0; + if (i == SIGRTMIN && name[0] != '+') + return 0; + if (!isdigit((unsigned char)name[1])) + return 0; + offs = strtol(name+1, , 10); + if (ep == name+1 || *ep != '\0' || + offs < 0 || offs > SIGRTMAX-SIGRTMIN) + return 0; + if (name[0] == '+') + i += (int)offs; + else + i -= (int)offs; + if (i >= SIGRTMIN && i <= SIGRTMAX) + return i; + } +#endif return 0; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Tue Aug 18 19:18:06 UTC 2020 Modified Files: src/lib/libc/gen: dehumanize_number.c Log Message: make sure errno is always set when we return -1 (Anon Ymous) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/lib/libc/gen/dehumanize_number.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/dehumanize_number.c diff -u src/lib/libc/gen/dehumanize_number.c:1.7 src/lib/libc/gen/dehumanize_number.c:1.8 --- src/lib/libc/gen/dehumanize_number.c:1.7 Wed Oct 1 09:53:04 2014 +++ src/lib/libc/gen/dehumanize_number.c Tue Aug 18 15:18:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $ */ +/* $NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $ */ /* * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $"); +__RCSID("$NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -104,8 +104,10 @@ dehumanize_number(const char *str, int64 errno = 0; tmp = strtoll(str, , 10); - if (str[0] == '\0' || (ep != delimit && *ep != '\0')) + if (str[0] == '\0' || (ep != delimit && *ep != '\0')) { + errno = EINVAL; return -1; /* Not a number. */ + } else if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN)) return -1; /* Out of range. */
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Jul 5 01:09:48 UTC 2020 Modified Files: src/lib/libc/gen: Makefile.inc endutxent.3 Log Message: revert previous; utmpxname is already documented in getlastlogx.3. Should probably be moved. To generate a diff of this commit: cvs rdiff -u -r1.204 -r1.205 src/lib/libc/gen/Makefile.inc cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gen/endutxent.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.204 src/lib/libc/gen/Makefile.inc:1.205 --- src/lib/libc/gen/Makefile.inc:1.204 Sat Jul 4 21:05:50 2020 +++ src/lib/libc/gen/Makefile.inc Sat Jul 4 21:09:48 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.204 2020/07/05 01:05:50 christos Exp $ +# $NetBSD: Makefile.inc,v 1.205 2020/07/05 01:09:48 christos Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -97,7 +97,7 @@ MLINKS+=directory.3 closedir.3 directory directory.3 fdopendir.3 MLINKS+=endutxent.3 getutxent.3 endutxent.3 getutxid.3 \ endutxent.3 getutxline.3 endutxent.3 pututxline.3 \ - endutxent.3 setutxent.3 endutmpx.3 utmpxname.3 + endutxent.3 setutxent.3 MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \ err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ err.3 vwarnc.3 Index: src/lib/libc/gen/endutxent.3 diff -u src/lib/libc/gen/endutxent.3:1.6 src/lib/libc/gen/endutxent.3:1.7 --- src/lib/libc/gen/endutxent.3:1.6 Sat Jul 4 21:05:50 2020 +++ src/lib/libc/gen/endutxent.3 Sat Jul 4 21:09:48 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: endutxent.3,v 1.6 2020/07/05 01:05:50 christos Exp $ +.\" $NetBSD: endutxent.3,v 1.7 2020/07/05 01:09:48 christos Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 4, 2020 +.Dd September 26, 2002 .Dt ENDUTXENT 3 .Os .Sh NAME @@ -36,8 +36,7 @@ .Nm getutxid , .Nm getutxline , .Nm pututxline , -.Nm setutxent , -.Nm utxname +.Nm setutxent .Nd user accounting database functions .Sh LIBRARY .Lb libc @@ -48,15 +47,13 @@ .Ft struct utmpx * .Fn getutxent void .Ft struct utmpx * -.Fn getutxid "const struct utmpx *ut" +.Fn getutxid "const struct utmpx *" .Ft struct utmpx * -.Fn getutxline "const struct utmpx *ut" +.Fn getutxline "const struct utmpx *" .Ft struct utmpx * -.Fn pututxline "const struct utmpx *ut" +.Fn pututxline "const struct utmpx *" .Ft void .Fn setutxent void -.Ft void -.Fn utmpxname "const char *fname" .Sh DESCRIPTION These functions provide access to the .Xr utmpx 5 @@ -94,10 +91,6 @@ adds the argument .Xr utmpx 5 entry line to the accounting database, replacing a previous entry for the same user if it exists. -.Pp -.Fn utmpxname -set sets the database file to -.Fa fname . .Ss The utmpx structure The .Nm utmpx @@ -162,12 +155,6 @@ if no match was found. .Fn pututxline returns the structure that was successfully written, or .Dv NULL . -.Fn utmpxname -returns -.Dv 1 -on success and -.Dv 0 -on failure. .Sh SEE ALSO .Xr logwtmpx 3 , .Xr utmpx 5 @@ -179,15 +166,10 @@ The .Fn getutxline , .Fn pututxline , .Fn setutxent -functions all conform to +all conform to .St -p1003.1-2001 (XSI extension), and previously to .St -xpg4.2 . -The -.Fn utxname -functions is a -.Nx -externsion. The fields .Fa ut_user , .Fa ut_id ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Jul 5 01:05:50 UTC 2020 Modified Files: src/lib/libc/gen: Makefile.inc endutxent.3 Log Message: document utmpxname(3) To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/lib/libc/gen/Makefile.inc cvs rdiff -u -r1.5 -r1.6 src/lib/libc/gen/endutxent.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.203 src/lib/libc/gen/Makefile.inc:1.204 --- src/lib/libc/gen/Makefile.inc:1.203 Sun May 10 15:36:49 2020 +++ src/lib/libc/gen/Makefile.inc Sat Jul 4 21:05:50 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.203 2020/05/10 19:36:49 maya Exp $ +# $NetBSD: Makefile.inc,v 1.204 2020/07/05 01:05:50 christos Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -97,7 +97,7 @@ MLINKS+=directory.3 closedir.3 directory directory.3 fdopendir.3 MLINKS+=endutxent.3 getutxent.3 endutxent.3 getutxid.3 \ endutxent.3 getutxline.3 endutxent.3 pututxline.3 \ - endutxent.3 setutxent.3 + endutxent.3 setutxent.3 endutmpx.3 utmpxname.3 MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \ err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ err.3 vwarnc.3 Index: src/lib/libc/gen/endutxent.3 diff -u src/lib/libc/gen/endutxent.3:1.5 src/lib/libc/gen/endutxent.3:1.6 --- src/lib/libc/gen/endutxent.3:1.5 Wed Apr 30 09:10:50 2008 +++ src/lib/libc/gen/endutxent.3 Sat Jul 4 21:05:50 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: endutxent.3,v 1.5 2008/04/30 13:10:50 martin Exp $ +.\" $NetBSD: endutxent.3,v 1.6 2020/07/05 01:05:50 christos Exp $ .\" .\" Copyright (c) 2002 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 26, 2002 +.Dd July 4, 2020 .Dt ENDUTXENT 3 .Os .Sh NAME @@ -36,7 +36,8 @@ .Nm getutxid , .Nm getutxline , .Nm pututxline , -.Nm setutxent +.Nm setutxent , +.Nm utxname .Nd user accounting database functions .Sh LIBRARY .Lb libc @@ -47,13 +48,15 @@ .Ft struct utmpx * .Fn getutxent void .Ft struct utmpx * -.Fn getutxid "const struct utmpx *" +.Fn getutxid "const struct utmpx *ut" .Ft struct utmpx * -.Fn getutxline "const struct utmpx *" +.Fn getutxline "const struct utmpx *ut" .Ft struct utmpx * -.Fn pututxline "const struct utmpx *" +.Fn pututxline "const struct utmpx *ut" .Ft void .Fn setutxent void +.Ft void +.Fn utmpxname "const char *fname" .Sh DESCRIPTION These functions provide access to the .Xr utmpx 5 @@ -91,6 +94,10 @@ adds the argument .Xr utmpx 5 entry line to the accounting database, replacing a previous entry for the same user if it exists. +.Pp +.Fn utmpxname +set sets the database file to +.Fa fname . .Ss The utmpx structure The .Nm utmpx @@ -155,6 +162,12 @@ if no match was found. .Fn pututxline returns the structure that was successfully written, or .Dv NULL . +.Fn utmpxname +returns +.Dv 1 +on success and +.Dv 0 +on failure. .Sh SEE ALSO .Xr logwtmpx 3 , .Xr utmpx 5 @@ -166,10 +179,15 @@ The .Fn getutxline , .Fn pututxline , .Fn setutxent -all conform to +functions all conform to .St -p1003.1-2001 (XSI extension), and previously to .St -xpg4.2 . +The +.Fn utxname +functions is a +.Nx +externsion. The fields .Fa ut_user , .Fa ut_id ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Tue Jun 2 19:30:29 UTC 2020 Modified Files: src/lib/libc/gen: timespec_get.3 Log Message: timespec_get(3) was developed by myself Remove FreeBSD from the authorship as it was just a pullup of small documentation changes. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gen/timespec_get.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/timespec_get.3 diff -u src/lib/libc/gen/timespec_get.3:1.4 src/lib/libc/gen/timespec_get.3:1.5 --- src/lib/libc/gen/timespec_get.3:1.4 Mon Aug 13 06:08:48 2018 +++ src/lib/libc/gen/timespec_get.3 Tue Jun 2 19:30:29 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: timespec_get.3,v 1.4 2018/08/13 06:08:48 wiz Exp $ +.\" $NetBSD: timespec_get.3,v 1.5 2020/06/02 19:30:29 kamil Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 10, 2018 +.Dd June 2, 2020 .Dt TIMESPEC_GET 3 .Os .Sh NAME @@ -81,4 +81,3 @@ This interface first appeared in .Nx 8 . .Sh AUTHORS .An Kamil Rytarowski Aq Mt ka...@netbsd.org -.An Warner Losh Aq Mt i...@freebsd.org
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Mon May 11 14:54:34 UTC 2020 Modified Files: src/lib/libc/gen: posix_spawnp.c Log Message: Do as the manual says, and use _PATH_DEFPATH if PATH is not present in the environment rather than simply turning into posix_spawn() in that case. Also, we cannot use strtok() to parse PATH, the semantics don't fit the API. Borrow the guts of execvp for the PATH search. We still simply check for a file with 'x' permission, and assume that one will do, whatever it is, which isn't really correct, but ... To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/gen/posix_spawnp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/posix_spawnp.c diff -u src/lib/libc/gen/posix_spawnp.c:1.3 src/lib/libc/gen/posix_spawnp.c:1.4 --- src/lib/libc/gen/posix_spawnp.c:1.3 Thu Jan 4 20:57:29 2018 +++ src/lib/libc/gen/posix_spawnp.c Mon May 11 14:54:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: posix_spawnp.c,v 1.3 2018/01/04 20:57:29 kamil Exp $ */ +/* $NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,17 +31,19 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: posix_spawnp.c,v 1.3 2018/01/04 20:57:29 kamil Exp $"); +__RCSID("$NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" +#include +#include +#include +#include #include -#include #include -#include +#include #include -#include int posix_spawnp(pid_t * __restrict pid, const char * __restrict file, @@ -49,31 +51,91 @@ int posix_spawnp(pid_t * __restrict pid, const posix_spawnattr_t * __restrict sa, char * const *__restrict cav, char * const *__restrict env) { - char fpath[FILENAME_MAX], *last, *p; - char *path; + char fpath[FILENAME_MAX]; + const char *path, *p; + size_t lp, ln; + int err; + + _DIAGASSERT(file != NULL); /* - * If there is a / in the filename, or no PATH environment variable - * set, fall straight through to posix_spawn(). + * If there is a / in the name, fall straight through to posix_spawn(). */ - if (strchr(file, '/') != NULL || (path = getenv("PATH")) == NULL) + if (strchr(file, '/') != NULL) return posix_spawn(pid, file, fa, sa, cav, env); - path = strdup(path); - if (path == NULL) - return ENOMEM; + /* Get the path we're searching. */ + if ((path = getenv("PATH")) == NULL) + path = _PATH_DEFPATH; /* * Find an executable image with the given name in the PATH */ - for (p = strtok_r(path, ":", ); p; - p = strtok_r(NULL, ":", )) { - snprintf(fpath, sizeof fpath, "%s/%s", p, file); - fpath[FILENAME_MAX-1] = 0; + + ln = strlen(file); + err = 0; + do { + /* Find the end of this path element. */ + for (p = path; *path != 0 && *path != ':'; path++) + continue; + /* + * It's a SHELL path -- double, leading and trailing colons + * mean the current directory. + */ + if (p == path) { + p = "."; + lp = 1; + } else + lp = (size_t)(path - p); + + /* + * Once we gain chdir/fchdir file actions, this will need + * serious work, as we must treat "." relative to the + * target of the (final) chdir performed. + * + * Fortunately, that day is yet to come. + */ + + /* + * If the path is too long complain. This is a possible + * security issue; given a way to make the path too long + * the user may execute the wrong program. + */ + if (lp + ln + 2 > sizeof(fpath)) { + (void)write(STDERR_FILENO, "posix_spawnp: ", 14); + (void)write(STDERR_FILENO, p, lp); + (void)write(STDERR_FILENO, ": path too long\n", 16); + continue; + } + memcpy(fpath, p, lp); + fpath[lp] = '/'; + memcpy(fpath + lp + 1, file, ln); + fpath[lp + ln + 1] = '\0'; + + /* + * It would be nice (much better) to try posix_spawn() + * here, using the current fpath as the filename, but + * there's no guarantee that it is safe to execute it + * twice (the file actions may screw us) so that we + * cannot do. This test is weak, barely even adequate. + * but unless we are forced into making posix_spawmp() + * become a system call (with PATH as an arg, or an array + * of possible paths to try, based upon PATH and file) + * we really have no better method. + */ if (access(fpath, X_OK) == 0) break; - } - free(path); + + if (err == 0) + err = errno; + + fpath[0] = '\0'; + + + } while (*path++ == ':'); /* Otherwise, *path was NUL */ + + if (fpath[0] == '\0') + return err; /* * Use posix_spawn() with the found binary
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Sun May 10 19:36:49 UTC 2020 Modified Files: src/lib/libc/gen: Makefile.inc Log Message: Don't add getentropy.c to the build (remove symbol from libc) Still being discussed in tech-userlevel. If we wait any longer someone is going to try the excuse that the discussion is entirely pointless, since removing symbols is too hard. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.202 src/lib/libc/gen/Makefile.inc:1.203 --- src/lib/libc/gen/Makefile.inc:1.202 Wed May 6 16:17:36 2020 +++ src/lib/libc/gen/Makefile.inc Sun May 10 19:36:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.202 2020/05/06 16:17:36 nia Exp $ +# $NetBSD: Makefile.inc,v 1.203 2020/05/10 19:36:49 maya Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -15,7 +15,7 @@ SRCS+= alarm.c alphasort.c arc4random.c errc.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \ exect.c extattr.c fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \ fts.c ftw.c getbsize.c getcap.c getcwd.c \ - getdevmajor.c getdomainname.c getentropy.c getgrent.c \ + getdevmajor.c getdomainname.c getgrent.c \ getgrouplist.c getgroupmembership.c gethostname.c \ getloadavg.c getlogin.c getmntinfo.c \ getnetgrent.c getpagesize.c \
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Thu May 7 12:55:06 UTC 2020 Modified Files: src/lib/libc/gen: getentropy.3 Log Message: Fix macro usage. Fix typo. New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/getentropy.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/getentropy.3 diff -u src/lib/libc/gen/getentropy.3:1.1 src/lib/libc/gen/getentropy.3:1.2 --- src/lib/libc/gen/getentropy.3:1.1 Wed May 6 16:17:36 2020 +++ src/lib/libc/gen/getentropy.3 Thu May 7 12:55:06 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: getentropy.3,v 1.1 2020/05/06 16:17:36 nia Exp $ $ +.\" $NetBSD: getentropy.3,v 1.2 2020/05/07 12:55:06 wiz Exp $ $ .\" .\" Copyright (c) 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -40,16 +40,15 @@ .Ft int .Fn getentropy "void *buf" "size_t buflen" .Sh DESCRIPTION -.Pp The .Fn getentropy function fills a buffer with high quality random data, suitable for seeding -cryptographically secure psuedorandom number generators. +cryptographically secure pseudo-random number generators. .Pp .Fn getentropy is only intended for seeding random number generators and is not intended -for use by regular code which simply needs secure random data. For this -purpose, please use +for use by regular code which simply needs secure random data. +For this purpose, please use .Xr arc4random 3 . .Pp The maximum value for @@ -64,7 +63,7 @@ variable .Sh RETURN VALUES The .Fn getentropy -function returns 0 on success, and -1 if an error occurred. +function returns 0 on success, and \-1 if an error occurred. .Sh ERRORS .Fn getentropy will succeed unless: @@ -75,6 +74,7 @@ The argument points to an invalid memory address. .It Bq Er EIO Too many bytes were requested. +.El .Sh SEE ALSO .Xr arc4random 3 , .Xr rnd 4
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Mon Mar 30 22:14:48 UTC 2020 Modified Files: src/lib/libc/gen: nlist.3 Log Message: Add comma in enumeration. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/nlist.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/nlist.3 diff -u src/lib/libc/gen/nlist.3:1.13 src/lib/libc/gen/nlist.3:1.14 --- src/lib/libc/gen/nlist.3:1.13 Mon Mar 30 20:37:03 2020 +++ src/lib/libc/gen/nlist.3 Mon Mar 30 22:14:48 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: nlist.3,v 1.13 2020/03/30 20:37:03 maya Exp $ +.\" $NetBSD: nlist.3,v 1.14 2020/03/30 22:14:48 wiz Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -71,7 +71,7 @@ if the file .Fa filename does not exist or is not executable, the returned value is \-1. .Sh SEE ALSO -.Xr a.out 5 +.Xr a.out 5 , .Xr elf 5 .Sh HISTORY A
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Mon Mar 30 20:37:04 UTC 2020 Modified Files: src/lib/libc/gen: nlist.3 Log Message: Mention elf rather than a.out some more. (Also, inspired by freebsd, which removed the non-elf support) To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/nlist.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/nlist.3 diff -u src/lib/libc/gen/nlist.3:1.12 src/lib/libc/gen/nlist.3:1.13 --- src/lib/libc/gen/nlist.3:1.12 Mon Mar 30 20:35:12 2020 +++ src/lib/libc/gen/nlist.3 Mon Mar 30 20:37:03 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: nlist.3,v 1.12 2020/03/30 20:35:12 maya Exp $ +.\" $NetBSD: nlist.3,v 1.13 2020/03/30 20:37:03 maya Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -48,7 +48,7 @@ function retrieves name list entries from the symbol table of an executable file. (See -.Xr a.out 5 . ) +.Xr elf 5 . ) The argument .Fa \ is set to reference the
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Mon Mar 30 20:35:12 UTC 2020 Modified Files: src/lib/libc/gen: nlist.3 Log Message: xref elf(5). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/nlist.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/nlist.3 diff -u src/lib/libc/gen/nlist.3:1.11 src/lib/libc/gen/nlist.3:1.12 --- src/lib/libc/gen/nlist.3:1.11 Thu Aug 7 16:42:53 2003 +++ src/lib/libc/gen/nlist.3 Mon Mar 30 20:35:12 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: nlist.3,v 1.11 2003/08/07 16:42:53 agc Exp $ +.\" $NetBSD: nlist.3,v 1.12 2020/03/30 20:35:12 maya Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)nlist.3 8.3 (Berkeley) 4/19/94 .\" -.Dd April 19, 1994 +.Dd March 30, 2020 .Dt NLIST 3 .Os .Sh NAME @@ -72,6 +72,7 @@ if the file does not exist or is not executable, the returned value is \-1. .Sh SEE ALSO .Xr a.out 5 +.Xr elf 5 .Sh HISTORY A .Fn nlist
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Mon Mar 30 20:34:11 UTC 2020 Modified Files: src/lib/libc/gen: nlist_private.h Log Message: Be less of a minefield for new architectures. They're not going to be a.out. Remove sh5, long gone. (Hopefully nothing hits the #else case) To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libc/gen/nlist_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/nlist_private.h diff -u src/lib/libc/gen/nlist_private.h:1.25 src/lib/libc/gen/nlist_private.h:1.26 --- src/lib/libc/gen/nlist_private.h:1.25 Fri Jan 29 21:38:35 2016 +++ src/lib/libc/gen/nlist_private.h Mon Mar 30 20:34:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist_private.h,v 1.25 2016/01/29 21:38:35 christos Exp $ */ +/* $NetBSD: nlist_private.h,v 1.26 2020/03/30 20:34:11 maya Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou @@ -54,9 +54,6 @@ # define NLIST_AOUT # define NLIST_ELF32 # define NLIST_ELF64 -#elif defined(__SH5__) -# define NLIST_ELF32 -# define NLIST_ELF64 #elif defined(__sh__) # define NLIST_COFF # define NLIST_ELF32 @@ -74,10 +71,7 @@ #elif defined(__or1k__) # define NLIST_ELF32 #else -# define NLIST_AOUT -/* #define NLIST_ECOFF */ -/* #define NLIST_ELF32 */ -/* #define NLIST_ELF64 */ +# error "Add your architecture here" #endif #define ISLAST(p) (N_NAME(p) == 0 || N_NAME(p)[0] == 0)
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon Mar 2 15:30:25 UTC 2020 Modified Files: src/lib/libc/gen: xsyslog.c Log Message: Add sysloglike attr. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/xsyslog.c diff -u src/lib/libc/gen/xsyslog.c:1.6 src/lib/libc/gen/xsyslog.c:1.7 --- src/lib/libc/gen/xsyslog.c:1.6 Mon Mar 2 09:10:24 2020 +++ src/lib/libc/gen/xsyslog.c Mon Mar 2 10:30:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xsyslog.c,v 1.6 2020/03/02 14:10:24 christos Exp $ */ +/* $NetBSD: xsyslog.c,v 1.7 2020/03/02 15:30:25 christos Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: xsyslog.c,v 1.6 2020/03/02 14:10:24 christos Exp $"); +__RCSID("$NetBSD: xsyslog.c,v 1.7 2020/03/02 15:30:25 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -124,7 +124,7 @@ _closelog_unlocked_r(struct syslog_data data->log_connected = 0; } -static void +static __sysloglike(6, 7) void _xsyslogp_r(int pri, struct syslog_fun *fun, struct syslog_data *data, const char *msgid, const char *sdfmt, const char *msgfmt, ...)
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon Mar 2 14:18:50 UTC 2020 Modified Files: src/lib/libc/gen: syslog_private.h Log Message: fix print-like attrs To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/syslog_private.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/syslog_private.h diff -u src/lib/libc/gen/syslog_private.h:1.2 src/lib/libc/gen/syslog_private.h:1.3 --- src/lib/libc/gen/syslog_private.h:1.2 Wed Jan 11 20:58:39 2017 +++ src/lib/libc/gen/syslog_private.h Mon Mar 2 09:18:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog_private.h,v 1.2 2017/01/12 01:58:39 christos Exp $ */ +/* $NetBSD: syslog_private.h,v 1.3 2020/03/02 14:18:50 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -40,13 +40,13 @@ struct syslog_fun { size_t (*timefun)(char *, size_t); int (*errfun)(int, char *, size_t); - int __printflike(3, 0) (*prfun)(char *, size_t, const char *, va_list); + int __sysloglike(3, 0) (*prfun)(char *, size_t, const char *, va_list); int (*lock)(const struct syslog_data *); int (*unlock)(const struct syslog_data *); }; -void _vxsyslogp_r(int , struct syslog_fun *, struct syslog_data *, -const char *, const char *, const char *, va_list); +void _vxsyslogp_r(int, struct syslog_fun *, struct syslog_data *, +const char *, const char *, const char *, va_list) __sysloglike(6, 0); void _openlog_unlocked_r(const char *, int, int, struct syslog_data *); void _closelog_unlocked_r(struct syslog_data *);
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon Mar 2 14:10:24 UTC 2020 Modified Files: src/lib/libc/gen: xsyslog.c Log Message: PR/55041: Fix printf format in syslog(3) error message. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/xsyslog.c diff -u src/lib/libc/gen/xsyslog.c:1.5 src/lib/libc/gen/xsyslog.c:1.6 --- src/lib/libc/gen/xsyslog.c:1.5 Tue Apr 18 08:34:07 2017 +++ src/lib/libc/gen/xsyslog.c Mon Mar 2 09:10:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xsyslog.c,v 1.5 2017/04/18 12:34:07 maya Exp $ */ +/* $NetBSD: xsyslog.c,v 1.6 2020/03/02 14:10:24 christos Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: xsyslog.c,v 1.5 2017/04/18 12:34:07 maya Exp $"); +__RCSID("$NetBSD: xsyslog.c,v 1.6 2020/03/02 14:10:24 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -160,7 +160,7 @@ _vxsyslogp_r(int pri, struct syslog_fun /* Check for invalid bits. */ if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { _xsyslogp_r(INTERNALLOG, &_syslog_ss_fun, data, NULL, NULL, - "%s: unknown facility/priority: %x", pri); + "Unknown facility/priority: %#x", pri); pri &= LOG_PRIMASK|LOG_FACMASK; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Feb 1 15:38:46 UTC 2020 Modified Files: src/lib/libc/gen: pthread_atfork.c Log Message: Switch atform allocations from malloc()+free() to mmap()+munmap() This avoid bootstrapping malloc too early when libc+libpthread are not ready. It is called through pthread__init() -> _pthread_atfork(). This also helps LLVM Leak Sanitizer to pacify false positive reports. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/pthread_atfork.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/pthread_atfork.c diff -u src/lib/libc/gen/pthread_atfork.c:1.10 src/lib/libc/gen/pthread_atfork.c:1.11 --- src/lib/libc/gen/pthread_atfork.c:1.10 Tue Jan 20 18:31:25 2015 +++ src/lib/libc/gen/pthread_atfork.c Sat Feb 1 15:38:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $ */ +/* $NetBSD: pthread_atfork.c,v 1.11 2020/02/01 15:38:46 kamil Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -31,15 +31,17 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $"); +__RCSID("$NetBSD: pthread_atfork.c,v 1.11 2020/02/01 15:38:46 kamil Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" +#include +#include +#include #include #include #include -#include #include "reentrant.h" #ifdef __weak_alias @@ -73,11 +75,22 @@ static struct atfork_callback_q childq = static struct atfork_callback * af_alloc(void) { + void *arena; + size_t sz; if (atfork_builtin.fn == NULL) return _builtin; - return malloc(sizeof(atfork_builtin)); + /* + * Avoid using here malloc() as this function is used on early init + * and can prematuraly initialize the malloc library. + * malloc() allocations here also confuse the LLVM Leak Sanitizer. + */ + sz = sizeof(atfork_builtin); + arena = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); + if (arena == MAP_FAILED) + return NULL; + return arena; } static void @@ -85,7 +98,7 @@ af_free(struct atfork_callback *af) { if (af != _builtin) - free(af); + munmap(af, sizeof(atfork_builtin)); } int
CVS commit: src/lib/libc/gen
Module Name:src Committed By: bad Date: Wed May 8 15:37:41 UTC 2019 Modified Files: src/lib/libc/gen: unvis.3 Log Message: Clarify that strunvisx() and strnunvisx() take the same flags as unvis(). Document VIS_NOESCAPE for unvis(). Bump date. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/unvis.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/unvis.3 diff -u src/lib/libc/gen/unvis.3:1.29 src/lib/libc/gen/unvis.3:1.30 --- src/lib/libc/gen/unvis.3:1.29 Tue Oct 24 19:14:55 2017 +++ src/lib/libc/gen/unvis.3 Wed May 8 15:37:41 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: unvis.3,v 1.29 2017/10/24 19:14:55 abhinav Exp $ +.\" $NetBSD: unvis.3,v 1.30 2019/05/08 15:37:41 bad Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)unvis.3 8.2 (Berkeley) 12/11/93 .\" -.Dd March 12, 2011 +.Dd May 8, 2019 .Dt UNVIS 3 .Os .Sh NAME @@ -99,16 +99,18 @@ should be equal to the size of .Pp The .Fn strunvisx -function does the same as the +and +.Fn strnunvisx +functions do the same as the .Fn strunvis -function, -but it allows you to add a flag that specifies the style the string +and +.Fn strnunvis +functions, +but take a flag that specifies the style the string .Ar src is encoded with. -Currently, the supported flags are: -.Dv VIS_HTTPSTYLE -and -.Dv VIS_MIMESTYLE . +The meaning of the flag is the same as explained below for +.Fn unvis . .Pp The .Fn unvis @@ -157,6 +159,10 @@ The .Fa flag argument is also used to specify the encoding style of the source. If set to +.Dv VIS_NOESCAPE +.Fn unvis +will not decode backslash escapes. +If set to .Dv VIS_HTTPSTYLE or .Dv VIS_HTTP1808 ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Tue Mar 12 22:21:53 UTC 2019 Modified Files: src/lib/libc/gen: humanize_number.3 Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/humanize_number.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/humanize_number.3 diff -u src/lib/libc/gen/humanize_number.3:1.12 src/lib/libc/gen/humanize_number.3:1.13 --- src/lib/libc/gen/humanize_number.3:1.12 Mon Mar 11 15:10:51 2019 +++ src/lib/libc/gen/humanize_number.3 Tue Mar 12 22:21:53 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: humanize_number.3,v 1.12 2019/03/11 15:10:51 kre Exp $ +.\" $NetBSD: humanize_number.3,v 1.13 2019/03/12 22:21:53 wiz Exp $ .\" .\" Copyright (c) 1999, 2002, 2008 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -89,7 +89,7 @@ The .Fa scale must be at least 0 and no more than 6. .Pp -Alternatively, one of fhe following special values may be given as +Alternatively, one of the following special values may be given as .Pa scale : .Bl -tag -width Dv -offset indent .It Dv HN_AUTOSCALE
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Mon Mar 11 15:10:51 UTC 2019 Modified Files: src/lib/libc/gen: humanize_number.3 humanize_number.c Log Message: PR lib/54053 When auto scaling, and the buffer is bigger than big enough for the biggest possible number, don't try and calculate the max value that will fit in the buffer - that calc will overflow (guaranteed) and is useless, the value we're formatting cannot possibly be bigger. So simply use the unscaled value (the raw number). While here, also avoid returning values that are larger than the buffer len ... while it would be nice to be able to find out how big the buffer should be so the data will fit, the interface doesn't really allow that (the buffer length passed in controls the scaling - at least when auto scaling) and the code already does "return -1" when it detects the buffer length is too small, even before it works out how much would have been needed. So, rather than returning a value > len (while truncating the result to fit in len ... all courtesy of snprintf()) return -1 in this case as well. Also, allow suffix==NULL (meaning "") - there's no reason not to, and requiring users to pass in an explicit "" is not useful. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/humanize_number.3 cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/humanize_number.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/humanize_number.3 diff -u src/lib/libc/gen/humanize_number.3:1.11 src/lib/libc/gen/humanize_number.3:1.12 --- src/lib/libc/gen/humanize_number.3:1.11 Sat Aug 20 21:35:32 2011 +++ src/lib/libc/gen/humanize_number.3 Mon Mar 11 15:10:51 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: humanize_number.3,v 1.11 2011/08/20 21:35:32 wiz Exp $ +.\" $NetBSD: humanize_number.3,v 1.12 2019/03/11 15:10:51 kre Exp $ .\" .\" Copyright (c) 1999, 2002, 2008 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 14, 2011 +.Dd March 11, 2019 .Dt HUMANIZE_NUMBER 3 .Os .Sh NAME @@ -47,21 +47,21 @@ function formats the signed 64 bit quant .Fa number into .Fa buffer . -A space and then +A space and then the .Fa suffix +.Pq "if not null" is appended to the end. -.Fa buffer -must be at least .Fa len -bytes long. +gives the size of the +.Fa buffer . .Pp If the formatted number (including .Fa suffix ) would be too long to fit into .Fa buffer , -then divide +then repeatedly divide .Fa number -by 1024 until it will. +by 1024 until it will fit. In this case, prefix .Fa suffix with the appropriate SI designator. @@ -85,11 +85,11 @@ in order to ensure a useful result is ge To use a specific prefix, specify this as .Fa scale (Multiplier = 1024 ^ scale). -This can not be combined with any of the +The .Fa scale -flags below. +must be at least 0 and no more than 6. .Pp -The following flags may be passed in +Alternatively, one of fhe following special values may be given as .Pa scale : .Bl -tag -width Dv -offset indent .It Dv HN_AUTOSCALE @@ -98,13 +98,20 @@ Format the buffer using the lowest multi Return the prefix index number (the number of times .Fa number must be divided to fit) instead of formatting it to the buffer. +That is, the +.Fa scale +that would have been used if +.Dv HN_AUTOSCALE +had been used. .El .Pp The following flags may be passed in .Pa flags : .Bl -tag -width Dv -offset indent .It Dv HN_DECIMAL -If the final result is less than 10, display it using one digit. +If the final numeric result is less than 10, +and is not the same as the original value (that is, it has been scaled) +display it using a decimal radix character, and one following digit. .It Dv HN_NOSPACE Do not put a space between .Fa number @@ -115,8 +122,22 @@ Use 'B' (bytes) as prefix if the origina Divide .Fa number with 1000 instead of 1024. +That is, use decimal scaling instead of binary. .El .Pp +To generate the shortest meaningful value, +a buffer length +.Pq Fa len +that is 6 greater the length of the +.Fa suffix +along with +.Dv HN_AUTOSCALE +will ensure the highest meaningful scale is used. +Allow one extra byte for the sign if the number is negative, +and one less if the +.Dv HN_NOSPACE +flag is used. +.Pp The .Fn dehumanize_number function parses the string representing an integral value given in Index: src/lib/libc/gen/humanize_number.c diff -u src/lib/libc/gen/humanize_number.c:1.17 src/lib/libc/gen/humanize_number.c:1.18 --- src/lib/libc/gen/humanize_number.c:1.17 Thu Apr 13 17:45:56 2017 +++ src/lib/libc/gen/humanize_number.c Mon Mar 11 15:10:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: humanize_number.c,v 1.17 2017/04/13 17:45:56 christos Exp $ */ +/* $NetBSD: humanize_number.c,v 1.18 2019/03/11 15:10:51 kre Exp $ */ /* * Copyright (c) 1997, 1998,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon Feb 18 20:27:20 UTC 2019 Modified Files: src/lib/libc/gen: devname.c Log Message: appease string + int warning. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libc/gen/devname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.c diff -u src/lib/libc/gen/devname.c:1.22 src/lib/libc/gen/devname.c:1.23 --- src/lib/libc/gen/devname.c:1.22 Sun Jun 3 17:42:46 2012 +++ src/lib/libc/gen/devname.c Mon Feb 18 15:27:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $ */ +/* $NetBSD: devname.c,v 1.23 2019/02/18 20:27:20 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $"); +__RCSID("$NetBSD: devname.c,v 1.23 2019/02/18 20:27:20 christos Exp $"); #include "namespace.h" #include "reentrant.h" @@ -95,7 +95,7 @@ devname_ptslookup(dev_t dev, mode_t type if (type != S_IFCHR || pts == NODEVMAJOR || major(dev) != pts) return ENOENT; - rv = snprintf(path, len, "%s%d", _PATH_DEV_PTS + sizeof(_PATH_DEV) - 1, + rv = snprintf(path, len, "%s%d", &_PATH_DEV_PTS[sizeof(_PATH_DEV) - 1], minor(dev)); if (rv < 0 || (size_t)rv >= len) return ERANGE;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Thu Jan 24 18:01:38 UTC 2019 Modified Files: src/lib/libc/gen: popen.c Log Message: PR/53904: Jintao Zhu: Use a mutex instead of an rwlock to assure thread safety To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/lib/libc/gen/popen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/popen.c diff -u src/lib/libc/gen/popen.c:1.35 src/lib/libc/gen/popen.c:1.36 --- src/lib/libc/gen/popen.c:1.35 Mon Feb 2 17:07:05 2015 +++ src/lib/libc/gen/popen.c Thu Jan 24 13:01:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.35 2015/02/02 22:07:05 christos Exp $ */ +/* $NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $ */ /* * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: popen.c,v 1.35 2015/02/02 22:07:05 christos Exp $"); +__RCSID("$NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -73,7 +73,20 @@ static struct pid { } *pidlist; #ifdef _REENTRANT -static rwlock_t pidlist_lock = RWLOCK_INITIALIZER; +static mutex_t pidlist_mutex = MUTEX_INITIALIZER; +# define MUTEX_LOCK() \ +do { \ + if (__isthreaded) \ + mutex_lock(_mutex); \ +} while (/*CONSTCOND*/0) +# define MUTEX_UNLOCK() \ +do { \ + if (__isthreaded) \ + mutex_unlock(_mutex); \ +} while (/*CONSTCOND*/0) +#else +# define MUTEX_LOCK() __nothing +# define MUTEX_UNLOCK() __nothing #endif static struct pid * @@ -183,17 +196,13 @@ popen(const char *cmd, const char *type) if ((cur = pdes_get(pdes, )) == NULL) return NULL; -#ifdef _REENTRANT - (void)rwlock_rdlock(_lock); -#endif + MUTEX_LOCK(); (void)__readlockenv(); switch (pid = vfork()) { case -1: /* Error. */ serrno = errno; (void)__unlockenv(); -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); pdes_error(pdes, cur); errno = serrno; return NULL; @@ -208,9 +217,7 @@ popen(const char *cmd, const char *type) pdes_parent(pdes, cur, pid, type); -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); return cur->fp; } @@ -228,15 +235,11 @@ popenve(const char *cmd, char *const *ar if ((cur = pdes_get(pdes, )) == NULL) return NULL; -#ifdef _REENTRANT - (void)rwlock_rdlock(_lock); -#endif + MUTEX_LOCK(); switch (pid = vfork()) { case -1: /* Error. */ serrno = errno; -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); pdes_error(pdes, cur); errno = serrno; return NULL; @@ -250,9 +253,7 @@ popenve(const char *cmd, char *const *ar pdes_parent(pdes, cur, pid, type); -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); return cur->fp; } @@ -271,18 +272,14 @@ pclose(FILE *iop) _DIAGASSERT(iop != NULL); -#ifdef _REENTRANT - rwlock_wrlock(_lock); -#endif + MUTEX_LOCK(); /* Find the appropriate file pointer. */ for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) if (cur->fp == iop) break; if (cur == NULL) { -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); errno = ESRCH; return -1; } @@ -295,9 +292,7 @@ pclose(FILE *iop) else last->next = cur->next; -#ifdef _REENTRANT - (void)rwlock_unlock(_lock); -#endif + MUTEX_UNLOCK(); do { pid = waitpid(cur->pid, , 0);
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Tue Jan 15 07:01:01 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Use \- for minus. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.30 src/lib/libc/gen/ctype.3:1.31 --- src/lib/libc/gen/ctype.3:1.30 Tue Jan 15 03:43:15 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 07:01:01 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.30 2019/01/15 03:43:15 uwe Exp $ +.\" $NetBSD: ctype.3,v 1.31 2019/01/15 07:01:01 wiz Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -197,7 +197,7 @@ However, this is not an excuse for avoid .Vt unsigned char : if .Dv EOF -coincides with any such value, as it does when it is -1 on platforms +coincides with any such value, as it does when it is \-1 on platforms with signed .Vt char , programs that pass
CVS commit: src/lib/libc/gen
Module Name:src Committed By: uwe Date: Tue Jan 15 03:43:15 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Fly, nasal demons, fly away... To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.29 src/lib/libc/gen/ctype.3:1.30 --- src/lib/libc/gen/ctype.3:1.29 Tue Jan 15 03:30:58 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 03:43:15 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.29 2019/01/15 03:30:58 riastradh Exp $ +.\" $NetBSD: ctype.3,v 1.30 2019/01/15 03:43:15 uwe Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -170,8 +170,7 @@ When compiling this program, GCC reports passes .Vt char . At runtime, you may get nonsense answers for some inputs without the -cast \(em if you're lucky and it doesn't crash or make demons come flying -out of your nose: +cast \(em if you're lucky and it doesn't crash: .Bd -literal -offset indent % gcc -Wall -o test test.c test.c: In function 'main':
CVS commit: src/lib/libc/gen
Module Name:src Committed By: riastradh Date: Tue Jan 15 03:30:58 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Use the same variable for the locale example. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.28 src/lib/libc/gen/ctype.3:1.29 --- src/lib/libc/gen/ctype.3:1.28 Tue Jan 15 01:23:49 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 03:30:58 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.28 2019/01/15 01:23:49 uwe Exp $ +.\" $NetBSD: ctype.3,v 1.29 2019/01/15 03:30:58 riastradh Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -176,7 +176,7 @@ out of your nose: % gcc -Wall -o test test.c test.c: In function 'main': test.c:12:2: warning: array subscript has type 'char' -% LANG=C ./test $(printf '\e270') +% LC_CTYPE=C ./test $(printf '\e270') -72 5 184 0 % LC_CTYPE=C ./test $(printf '\e377')
CVS commit: src/lib/libc/gen
Module Name:src Committed By: uwe Date: Tue Jan 15 01:23:49 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Don't talk about "the first argument" when there's only one. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.27 src/lib/libc/gen/ctype.3:1.28 --- src/lib/libc/gen/ctype.3:1.27 Tue Jan 15 01:13:49 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 01:23:49 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.27 2019/01/15 01:13:49 uwe Exp $ +.\" $NetBSD: ctype.3,v 1.28 2019/01/15 01:23:49 uwe Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -97,7 +97,7 @@ All described functions, including also conform to .St -p1003.1-2001 . .Sh CAVEATS -The first argument of these functions is of type +The argument of these functions is of type .Vt int , but only a very restricted subset of values are actually valid. The argument must either be the value of the macro
CVS commit: src/lib/libc/gen
Module Name:src Committed By: uwe Date: Tue Jan 15 01:13:49 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Fix markup pasto. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.26 src/lib/libc/gen/ctype.3:1.27 --- src/lib/libc/gen/ctype.3:1.26 Tue Jan 15 01:11:03 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 01:13:49 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.26 2019/01/15 01:11:03 uwe Exp $ +.\" $NetBSD: ctype.3,v 1.27 2019/01/15 01:13:49 uwe Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -200,7 +200,7 @@ if .Dv EOF coincides with any such value, as it does when it is -1 on platforms with signed -.Dv char , +.Vt char , programs that pass .Vt char will still necessarily confuse the classification and mapping of
CVS commit: src/lib/libc/gen
Module Name:src Committed By: uwe Date: Tue Jan 15 01:11:03 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Remove the extra cast to int in the CAVEATS example. We removed it from EXAMPLES a few releases ago. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.25 src/lib/libc/gen/ctype.3:1.26 --- src/lib/libc/gen/ctype.3:1.25 Tue Jan 15 00:43:32 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 01:11:03 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.25 2019/01/15 00:43:32 uwe Exp $ +.\" $NetBSD: ctype.3,v 1.26 2019/01/15 01:11:03 uwe Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -161,7 +161,7 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); printf("%d %d\en", *argv[1], isprint(*argv[1])); printf("%d %d\en", (int)(unsigned char)*argv[1], - isprint((int)(unsigned char)*argv[1])); + isprint((unsigned char)*argv[1])); return 0; } .Ed @@ -170,19 +170,19 @@ When compiling this program, GCC reports passes .Vt char . At runtime, you may get nonsense answers for some inputs without the -cast -- if you're lucky and it doesn't crash or make demons come flying +cast \(em if you're lucky and it doesn't crash or make demons come flying out of your nose: .Bd -literal -offset indent % gcc -Wall -o test test.c test.c: In function 'main': test.c:12:2: warning: array subscript has type 'char' -% LANG=C ./test "`printf '\e270'`" +% LANG=C ./test $(printf '\e270') -72 5 184 0 -% LC_CTYPE=C ./test "`printf '\e377'`" +% LC_CTYPE=C ./test $(printf '\e377') -1 0 255 0 -% LC_CTYPE=fr_FR.ISO8859-1 ./test "`printf '\e377'`" +% LC_CTYPE=fr_FR.ISO8859-1 ./test $(printf '\e377') -1 0 255 2 .Ed
CVS commit: src/lib/libc/gen
Module Name:src Committed By: uwe Date: Tue Jan 15 00:43:32 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Fix typo in macro flag. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.24 src/lib/libc/gen/ctype.3:1.25 --- src/lib/libc/gen/ctype.3:1.24 Tue Jan 15 00:31:19 2019 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 00:43:32 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.24 2019/01/15 00:31:19 riastradh Exp $ +.\" $NetBSD: ctype.3,v 1.25 2019/01/15 00:43:32 uwe Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -147,7 +147,7 @@ inputs of type .Vt char in order to flag code that may pass negative values at runtime that would lead to undefined behavior: -.Bd -literal offset indent +.Bd -literal -offset indent #include #include #include
CVS commit: src/lib/libc/gen
Module Name:src Committed By: riastradh Date: Tue Jan 15 00:31:19 UTC 2019 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Expand on correct and incorrect usage, and on compiler warnings. Give an example program with the warning, and some example nonsense outputs. Also note why glibc's approach doesn't solve the problem. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.23 src/lib/libc/gen/ctype.3:1.24 --- src/lib/libc/gen/ctype.3:1.23 Tue Dec 12 14:13:52 2017 +++ src/lib/libc/gen/ctype.3 Tue Jan 15 00:31:19 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.23 2017/12/12 14:13:52 abhinav Exp $ +.\" $NetBSD: ctype.3,v 1.24 2019/01/15 00:31:19 riastradh Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -30,7 +30,7 @@ .\" .\" @(#)ctype.3 6.5 (Berkeley) 4/19/91 .\" -.Dd December 8, 2017 +.Dd January 15, 2019 .Dt CTYPE 3 .Os .Sh NAME @@ -136,3 +136,73 @@ which will be outside the range of allow (unless it happens to be equal to .Dv EOF , but even that would not give the desired result). +.Pp +Because the bugs may manifest as silent misbehavior or as crashes only +when fed input outside the US-ASCII range, the +.Nx +implementation of the +.Nm +functions is designed to elicit a compiler warning for code that passes +inputs of type +.Vt char +in order to flag code that may pass negative values at runtime that +would lead to undefined behavior: +.Bd -literal offset indent +#include +#include +#include + +int +main(int argc, char **argv) +{ + + if (argc < 2) + return 1; + setlocale(LC_ALL, ""); + printf("%d %d\en", *argv[1], isprint(*argv[1])); + printf("%d %d\en", (int)(unsigned char)*argv[1], + isprint((int)(unsigned char)*argv[1])); + return 0; +} +.Ed +.Pp +When compiling this program, GCC reports a warning for the line that +passes +.Vt char . +At runtime, you may get nonsense answers for some inputs without the +cast -- if you're lucky and it doesn't crash or make demons come flying +out of your nose: +.Bd -literal -offset indent +% gcc -Wall -o test test.c +test.c: In function 'main': +test.c:12:2: warning: array subscript has type 'char' +% LANG=C ./test "`printf '\e270'`" +-72 5 +184 0 +% LC_CTYPE=C ./test "`printf '\e377'`" +-1 0 +255 0 +% LC_CTYPE=fr_FR.ISO8859-1 ./test "`printf '\e377'`" +-1 0 +255 2 +.Ed +.Pp +Some implementations of libc, such as glibc as of 2018, attempt to +avoid the worst of the undefined behavior by defining the functions to +work for all integer inputs representable by either +.Vt unsigned char +or +.Vt char , +and suppress the warning. +However, this is not an excuse for avoiding conversion to +.Vt unsigned char : +if +.Dv EOF +coincides with any such value, as it does when it is -1 on platforms +with signed +.Dv char , +programs that pass +.Vt char +will still necessarily confuse the classification and mapping of +.Dv EOF +with the classification and mapping of some non-EOF inputs.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Thu Sep 27 00:45:34 UTC 2018 Modified Files: src/lib/libc/gen: dirname.c Log Message: HACK: if calling dirname() with the results of a previous dirname() there is no need to copy the path into the output buffer, it is already there All this has to change to become compat with a forthcoming POSIX update. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/dirname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/dirname.c diff -u src/lib/libc/gen/dirname.c:1.13 src/lib/libc/gen/dirname.c:1.14 --- src/lib/libc/gen/dirname.c:1.13 Wed Jul 16 10:52:26 2014 +++ src/lib/libc/gen/dirname.c Thu Sep 27 00:45:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $ */ +/* $NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $ */ /*- * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $"); +__RCSID("$NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $"); #endif /* !LIBC_SCCS && !lint */ #include "namespace.h" @@ -83,7 +83,8 @@ xdirname_r(const char *path, char *buf, out: if (buf != NULL && buflen != 0) { buflen = MIN(len, buflen - 1); - memcpy(buf, path, buflen); + if (buf != path) + memcpy(buf, path, buflen); buf[buflen] = '\0'; } return len;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maxv Date: Thu Sep 6 09:28:00 UTC 2018 Modified Files: src/lib/libc/gen: sysctl.3 Log Message: fix references, the things were moved into netipsec/ a while ago To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/lib/libc/gen/sysctl.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/sysctl.3 diff -u src/lib/libc/gen/sysctl.3:1.203 src/lib/libc/gen/sysctl.3:1.204 --- src/lib/libc/gen/sysctl.3:1.203 Mon Jul 3 21:32:49 2017 +++ src/lib/libc/gen/sysctl.3 Thu Sep 6 09:28:00 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.3,v 1.203 2017/07/03 21:32:49 wiz Exp $ +.\" $NetBSD: sysctl.3,v 1.204 2018/09/06 09:28:00 maxv Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" -.Dd June 13, 2014 +.Dd September 6, 2018 .Dt SYSCTL 3 .Os .Sh NAME @@ -665,9 +665,9 @@ definitions for fourth level TCP identif definitions for fourth level UDP identifiers .It Aq Pa netinet6/udp6_var.h definitions for fourth level IPv6 UDP identifiers -.It Aq Pa netinet6/ipsec.h +.It Aq Pa netipsec/ipsec.h definitions for fourth level IPsec identifiers -.It Aq Pa netkey/key_var.h +.It Aq Pa netipsec/key_var.h definitions for third level PF_KEY identifiers .It Aq Pa machine/cpu.h definitions for second level machdep identifiers
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Mon Aug 13 06:08:48 UTC 2018 Modified Files: src/lib/libc/gen: timespec_get.3 Log Message: Sort SEE ALSO. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/gen/timespec_get.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/timespec_get.3 diff -u src/lib/libc/gen/timespec_get.3:1.3 src/lib/libc/gen/timespec_get.3:1.4 --- src/lib/libc/gen/timespec_get.3:1.3 Fri Aug 10 20:35:52 2018 +++ src/lib/libc/gen/timespec_get.3 Mon Aug 13 06:08:48 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: timespec_get.3,v 1.3 2018/08/10 20:35:52 kamil Exp $ +.\" $NetBSD: timespec_get.3,v 1.4 2018/08/13 06:08:48 wiz Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -64,8 +64,8 @@ if successful, otherwise .Dv 0 on failure. .Sh SEE ALSO -.Xr gettimeofday 2 , .Xr clock_gettime 2 , +.Xr gettimeofday 2 , .Xr time 3 .Sh STANDARDS The
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Fri Aug 10 20:35:52 UTC 2018 Modified Files: src/lib/libc/gen: timespec_get.3 Log Message: Merge FreeBSD improvements to the man-page of timespec_get(3) Keep NetBSD references instead of FreeBSD ones included in the FreeBSD version. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/timespec_get.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/timespec_get.3 diff -u src/lib/libc/gen/timespec_get.3:1.2 src/lib/libc/gen/timespec_get.3:1.3 --- src/lib/libc/gen/timespec_get.3:1.2 Tue Oct 4 10:46:40 2016 +++ src/lib/libc/gen/timespec_get.3 Fri Aug 10 20:35:52 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: timespec_get.3,v 1.2 2016/10/04 10:46:40 wiz Exp $ +.\" $NetBSD: timespec_get.3,v 1.3 2018/08/10 20:35:52 kamil Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 4, 2016 +.Dd August 10, 2018 .Dt TIMESPEC_GET 3 .Os .Sh NAME @@ -37,7 +37,6 @@ .Lb libc .Sh SYNOPSIS .In time.h -.Vt #define TIME_UTC 1 .Ft int .Fn timespec_get "struct timespec *ts" "int base" .Sh DESCRIPTION @@ -48,9 +47,14 @@ function sets the interval pointed to by to hold the current calendar time based on the specified time base in .Fa base . .Pp -Currently the only supported valid base is -.Dv TIME_UTC . -It returns time elapsed since epoch. +The base +.Dv TIME_UTC +returns the time since the epoch. +This time is expressed in seconds and nanoseconds since midnight (0 hour), January 1, 1970. +In +.Nx , +this corresponds to +.Dv CLOCK_REALTIME . .Sh RETURN VALUES The .Nm @@ -59,16 +63,22 @@ function returns the passed value of if successful, otherwise .Dv 0 on failure. -.\" .Sh ERRORS .Sh SEE ALSO -.Xr clock_gettime 2 +.Xr gettimeofday 2 , +.Xr clock_gettime 2 , +.Xr time 3 .Sh STANDARDS The .Nm -function conforms to +function with a +.Fa base +of +.Dv TIME_UTC +conforms to .St -isoC-2011 . .Sh HISTORY This interface first appeared in .Nx 8 . .Sh AUTHORS .An Kamil Rytarowski Aq Mt ka...@netbsd.org +.An Warner Losh Aq Mt i...@freebsd.org
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Thu Jul 26 00:05:28 UTC 2018 Modified Files: src/lib/libc/gen: ftok.c Log Message: Avoid undefined behavior in ftok(3) Do not change the signedness bit with a left shift operation. Cast to unsigned integer to prevent this. ftok.c:56:10, left shift of 123456789 by 24 places cannot be represented in type 'int' ftok.c:56:10, left shift of 4160 by 24 places cannot be represented in type 'int' Detected with micro-UBSan in the user mode. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/ftok.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ftok.c diff -u src/lib/libc/gen/ftok.c:1.11 src/lib/libc/gen/ftok.c:1.12 --- src/lib/libc/gen/ftok.c:1.11 Tue Mar 20 16:36:05 2012 +++ src/lib/libc/gen/ftok.c Thu Jul 26 00:05:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $ */ +/* $NetBSD: ftok.c,v 1.12 2018/07/26 00:05:28 kamil Exp $ */ /* * Copyright (c) 1994 SigmaSoft, Th. Lockert @@ -27,7 +27,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $"); +__RCSID("$NetBSD: ftok.c,v 1.12 2018/07/26 00:05:28 kamil Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -53,5 +53,6 @@ ftok(const char *path, int id) return (key_t)-1; return (key_t) - (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0x)); + ((unsigned int)id << 24 | (st.st_dev & 0xff) << 16 | + (st.st_ino & 0x)); }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 13 06:43:46 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Revert change made by rev 1.11; now, fmtcheck(3) does not complain about unused trailing arguments as before. See also discussion on tech-userland: http://mail-index.netbsd.org/tech-userlevel/2017/12/07/msg011019.html To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.15 src/lib/libc/gen/fmtcheck.c:1.16 --- src/lib/libc/gen/fmtcheck.c:1.15 Wed Dec 6 14:05:14 2017 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 13 06:43:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.16 2017/12/13 06:43:45 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.16 2017/12/13 06:43:45 rin Exp $"); #endif #include "namespace.h" @@ -344,8 +344,5 @@ fmtcheck(const char *f1, const char *f2) if (f1t != f2t) return f2; } - if (get_next_format(, f2t) != FMTCHECK_DONE) - return f2; - else - return f1; + return f1; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Dec 12 14:13:52 UTC 2017 Modified Files: src/lib/libc/gen: ctype.3 Log Message: Add ctype to the NAME section (as this is a man page for ctype) Remove rest of the names from the NAME section (These names have their own individual man pages, as such it doesn't make sense to have their names in the NAME section in this man page as well. Moreover, we have been trying to fix such man pages so that apropos(1)/whatis(1) are able to search these man pages. Other examples of such fixed man pages include memory(3), string(3) etc.) ok wiz@ To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libc/gen/ctype.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/ctype.3 diff -u src/lib/libc/gen/ctype.3:1.22 src/lib/libc/gen/ctype.3:1.23 --- src/lib/libc/gen/ctype.3:1.22 Wed Feb 25 16:23:40 2015 +++ src/lib/libc/gen/ctype.3 Tue Dec 12 14:13:52 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ctype.3,v 1.22 2015/02/25 16:23:40 wiz Exp $ +.\" $NetBSD: ctype.3,v 1.23 2017/12/12 14:13:52 abhinav Exp $ .\" .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. @@ -30,24 +30,11 @@ .\" .\" @(#)ctype.3 6.5 (Berkeley) 4/19/91 .\" -.Dd February 25, 2015 +.Dd December 8, 2017 .Dt CTYPE 3 .Os .Sh NAME -.Nm isalpha , -.Nm isupper , -.Nm islower , -.Nm isdigit , -.Nm isxdigit , -.Nm isalnum , -.Nm isspace , -.Nm ispunct , -.Nm isprint , -.Nm isgraph , -.Nm iscntrl , -.Nm isblank , -.Nm toupper , -.Nm tolower , +.Nm ctype .Nd character classification and mapping functions .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: dholland Date: Wed Dec 6 16:38:22 UTC 2017 Modified Files: src/lib/libc/gen: signal.3 Log Message: The list of async-signal-safe functions got moved to sigaction(2). To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/lib/libc/gen/signal.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/signal.3 diff -u src/lib/libc/gen/signal.3:1.27 src/lib/libc/gen/signal.3:1.28 --- src/lib/libc/gen/signal.3:1.27 Mon Jun 6 08:28:18 2016 +++ src/lib/libc/gen/signal.3 Wed Dec 6 16:38:22 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: signal.3,v 1.27 2016/06/06 08:28:18 wiz Exp $ +.\" $NetBSD: signal.3,v 1.28 2017/12/06 16:38:22 dholland Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -149,7 +149,7 @@ ignored signals remain ignored. .Pp Only functions that are async-signal-safe can safely be used in signal handlers, see -.Xr signal 7 +.Xr sigaction 2 for a complete list. .Sh RETURN VALUES The previous action is returned on a successful call.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 6 14:05:14 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Fix possible use of uninitialized variable in case of WIN32 && !_WIN64. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.14 src/lib/libc/gen/fmtcheck.c:1.15 --- src/lib/libc/gen/fmtcheck.c:1.14 Wed Dec 6 12:32:02 2017 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 6 14:05:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.15 2017/12/06 14:05:14 rin Exp $"); #endif #include "namespace.h" @@ -149,11 +149,13 @@ get_next_format_from_precision(const cha f += 2; modifier = MOD_QUAD; } -#ifdef _WIN64 else { +#ifdef _WIN64 modifier = MOD_QUAD; - } +#else + modifier = MOD_NONE; #endif + } break; #endif default:
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 6 12:32:02 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Teach fmtcheck(3) about wint_t, intmax_t, char *, intmax_t *, and wide string arguments. Taken from FreeBSD: https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev181154 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.13 src/lib/libc/gen/fmtcheck.c:1.14 --- src/lib/libc/gen/fmtcheck.c:1.13 Wed Dec 6 12:30:27 2017 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 6 12:32:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.14 2017/12/06 12:32:02 rin Exp $"); #endif #include "namespace.h" @@ -47,20 +47,25 @@ enum __e_fmtcheck_types { FMTCHECK_START, FMTCHECK_SHORT, FMTCHECK_INT, + FMTCHECK_WINTT, FMTCHECK_LONG, FMTCHECK_QUAD, + FMTCHECK_INTMAXT, FMTCHECK_PTRDIFFT, FMTCHECK_SIZET, FMTCHECK_POINTER, + FMTCHECK_CHARPOINTER, FMTCHECK_SHORTPOINTER, FMTCHECK_INTPOINTER, FMTCHECK_LONGPOINTER, FMTCHECK_QUADPOINTER, + FMTCHECK_INTMAXTPOINTER, FMTCHECK_PTRDIFFTPOINTER, FMTCHECK_SIZETPOINTER, FMTCHECK_DOUBLE, FMTCHECK_LONGDOUBLE, FMTCHECK_STRING, + FMTCHECK_WSTRING, FMTCHECK_WIDTH, FMTCHECK_PRECISION, FMTCHECK_DONE, @@ -68,6 +73,18 @@ enum __e_fmtcheck_types { }; typedef enum __e_fmtcheck_types EFT; +enum e_modifier { + MOD_NONE, + MOD_CHAR, + MOD_SHORT, + MOD_LONG, + MOD_QUAD, + MOD_INTMAXT, + MOD_LONGDOUBLE, + MOD_PTRDIFFT, + MOD_SIZET, +}; + #define RETURN(pf,f,r) do { \ *(pf) = (f); \ return r; \ @@ -76,42 +93,50 @@ typedef enum __e_fmtcheck_types EFT; static EFT get_next_format_from_precision(const char **pf) { - int sh, lg, quad, longdouble, ptrdifft, sizet; + enum e_modifier modifier; const char *f; - sh = lg = quad = longdouble = ptrdifft = sizet = 0; - f = *pf; switch (*f) { case 'h': f++; - sh = 1; + if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); + if (*f == 'h') { + f++; + modifier = MOD_CHAR; + } else { + modifier = MOD_SHORT; + } + break; + case 'j': + f++; + modifier = MOD_INTMAXT; break; case 'l': f++; if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); if (*f == 'l') { f++; - quad = 1; + modifier = MOD_QUAD; } else { - lg = 1; + modifier = MOD_LONG; } break; case 'q': f++; - quad = 1; + modifier = MOD_QUAD; break; case 't': f++; - ptrdifft = 1; + modifier = MOD_PTRDIFFT; break; case 'z': f++; - sizet = 1; + modifier = MOD_SIZET; break; case 'L': f++; - longdouble = 1; + modifier = MOD_LONGDOUBLE; break; #ifdef WIN32 case 'I': @@ -119,73 +144,113 @@ get_next_format_from_precision(const cha if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); if (*f == '3' && f[1] == '2') { f += 2; + modifier = MOD_NONE; } else if (*f == '6' && f[1] == '4') { f += 2; - quad = 1; + modifier = MOD_QUAD; } #ifdef _WIN64 else { - quad = 1; + modifier = MOD_QUAD; } #endif break; #endif default: + modifier = MOD_NONE; break; } if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); if (strchr("diouxX", *f)) { - if (longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - if (lg) + switch (modifier) { + case MOD_LONG: RETURN(pf,f,FMTCHECK_LONG); - if (quad) + case MOD_QUAD: RETURN(pf,f,FMTCHECK_QUAD); - if (ptrdifft) + case MOD_INTMAXT: + RETURN(pf,f,FMTCHECK_INTMAXT); + case MOD_PTRDIFFT: RETURN(pf,f,FMTCHECK_PTRDIFFT); - if (sizet) + case MOD_SIZET: RETURN(pf,f,FMTCHECK_SIZET); - RETURN(pf,f,FMTCHECK_INT); + case MOD_CHAR: + case MOD_SHORT: + case MOD_NONE: + RETURN(pf,f,FMTCHECK_INT); + default: + RETURN(pf,f,FMTCHECK_UNKNOWN); + } } if (*f == 'n') { - if (longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - if (sh) + switch (modifier) { + case MOD_CHAR: + RETURN(pf,f,FMTCHECK_CHARPOINTER); + case MOD_SHORT: RETURN(pf,f,FMTCHECK_SHORTPOINTER); - if (lg) + case MOD_LONG: RETURN(pf,f,FMTCHECK_LONGPOINTER); - if (quad) + case MOD_QUAD: RETURN(pf,f,FMTCHECK_QUADPOINTER); - if (ptrdifft) + case MOD_INTMAXT: + RETURN(pf,f,FMTCHECK_INTMAXTPOINTER); + case MOD_PTRDIFFT: RETURN(pf,f,FMTCHECK_PTRDIFFTPOINTER); - if (sizet) + case MOD_SIZET: RETURN(pf,f,FMTCHECK_SIZETPOINTER); - RETURN(pf,f,FMTCHECK_INTPOINTER); + case MOD_NONE: + RETURN(pf,f,FMTCHECK_INTPOINTER); + default: + RETURN(pf,f,FMTCHECK_UNKNOWN); + } } if (strchr("DOU", *f)) { - if (sh + lg + quad +
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 6 12:30:27 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Teach fmtcheck(3) about the ' (thousands separator) flag. Taken from FreeBSD: https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev143905 To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.12 src/lib/libc/gen/fmtcheck.c:1.13 --- src/lib/libc/gen/fmtcheck.c:1.12 Wed Dec 6 12:28:53 2017 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 6 12:30:27 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.13 2017/12/06 12:30:27 rin Exp $"); #endif #include "namespace.h" @@ -242,7 +242,7 @@ get_next_format(const char **pf, EFT eft } /* Eat any of the flags */ - while (*f && (strchr("#0- +", *f))) + while (*f && (strchr("#'0- +", *f))) f++; if (*f == '*') {
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 6 12:28:53 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Teach fmtcheck(3) about the flags a, A, F, G, t, and z. Taken from FreeBSD: https://svnweb.freebsd.org/base/head/lib/libc/gen/fmtcheck.c#rev117014 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.11 src/lib/libc/gen/fmtcheck.c:1.12 --- src/lib/libc/gen/fmtcheck.c:1.11 Wed Dec 6 11:33:34 2017 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 6 12:28:53 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.12 2017/12/06 12:28:53 rin Exp $"); #endif #include "namespace.h" @@ -49,11 +49,15 @@ enum __e_fmtcheck_types { FMTCHECK_INT, FMTCHECK_LONG, FMTCHECK_QUAD, + FMTCHECK_PTRDIFFT, + FMTCHECK_SIZET, FMTCHECK_POINTER, FMTCHECK_SHORTPOINTER, FMTCHECK_INTPOINTER, FMTCHECK_LONGPOINTER, FMTCHECK_QUADPOINTER, + FMTCHECK_PTRDIFFTPOINTER, + FMTCHECK_SIZETPOINTER, FMTCHECK_DOUBLE, FMTCHECK_LONGDOUBLE, FMTCHECK_STRING, @@ -72,10 +76,10 @@ typedef enum __e_fmtcheck_types EFT; static EFT get_next_format_from_precision(const char **pf) { - int sh, lg, quad, longdouble; + int sh, lg, quad, longdouble, ptrdifft, sizet; const char *f; - sh = lg = quad = longdouble = 0; + sh = lg = quad = longdouble = ptrdifft = sizet = 0; f = *pf; switch (*f) { @@ -97,6 +101,14 @@ get_next_format_from_precision(const cha f++; quad = 1; break; + case 't': + f++; + ptrdifft = 1; + break; + case 'z': + f++; + sizet = 1; + break; case 'L': f++; longdouble = 1; @@ -129,6 +141,10 @@ get_next_format_from_precision(const cha RETURN(pf,f,FMTCHECK_LONG); if (quad) RETURN(pf,f,FMTCHECK_QUAD); + if (ptrdifft) + RETURN(pf,f,FMTCHECK_PTRDIFFT); + if (sizet) + RETURN(pf,f,FMTCHECK_SIZET); RETURN(pf,f,FMTCHECK_INT); } if (*f == 'n') { @@ -140,32 +156,36 @@ get_next_format_from_precision(const cha RETURN(pf,f,FMTCHECK_LONGPOINTER); if (quad) RETURN(pf,f,FMTCHECK_QUADPOINTER); + if (ptrdifft) + RETURN(pf,f,FMTCHECK_PTRDIFFTPOINTER); + if (sizet) + RETURN(pf,f,FMTCHECK_SIZETPOINTER); RETURN(pf,f,FMTCHECK_INTPOINTER); } if (strchr("DOU", *f)) { - if (sh + lg + quad + longdouble) + if (sh + lg + quad + longdouble + ptrdifft + sizet) RETURN(pf,f,FMTCHECK_UNKNOWN); RETURN(pf,f,FMTCHECK_LONG); } - if (strchr("eEfg", *f)) { + if (strchr("aAeEfFgG", *f)) { if (longdouble) RETURN(pf,f,FMTCHECK_LONGDOUBLE); - if (sh + lg + quad) + if (sh + lg + quad + ptrdifft + sizet) RETURN(pf,f,FMTCHECK_UNKNOWN); RETURN(pf,f,FMTCHECK_DOUBLE); } if (*f == 'c') { - if (sh + lg + quad + longdouble) + if (sh + lg + quad + longdouble + ptrdifft + sizet) RETURN(pf,f,FMTCHECK_UNKNOWN); RETURN(pf,f,FMTCHECK_INT); } if (*f == 's') { - if (sh + lg + quad + longdouble) + if (sh + lg + quad + longdouble + ptrdifft + sizet) RETURN(pf,f,FMTCHECK_UNKNOWN); RETURN(pf,f,FMTCHECK_STRING); } if (*f == 'p') { - if (sh + lg + quad + longdouble) + if (sh + lg + quad + longdouble + ptrdifft + sizet) RETURN(pf,f,FMTCHECK_UNKNOWN); RETURN(pf,f,FMTCHECK_POINTER); }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Wed Dec 6 11:33:35 UTC 2017 Modified Files: src/lib/libc/gen: fmtcheck.c Log Message: Correct oversight of wrong format string with fewer number of arguments than default format string has. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libc/gen/fmtcheck.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fmtcheck.c diff -u src/lib/libc/gen/fmtcheck.c:1.10 src/lib/libc/gen/fmtcheck.c:1.11 --- src/lib/libc/gen/fmtcheck.c:1.10 Wed Jan 20 15:43:05 2016 +++ src/lib/libc/gen/fmtcheck.c Wed Dec 6 11:33:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fmtcheck.c,v 1.10 2016/01/20 15:43:05 christos Exp $ */ +/* $NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.10 2016/01/20 15:43:05 christos Exp $"); +__RCSID("$NetBSD: fmtcheck.c,v 1.11 2017/12/06 11:33:34 rin Exp $"); #endif #include "namespace.h" @@ -257,5 +257,8 @@ fmtcheck(const char *f1, const char *f2) if (f1t != f2t) return f2; } - return f1; + if (get_next_format(, f2t) != FMTCHECK_DONE) + return f2; + else + return f1; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon Nov 27 16:37:21 UTC 2017 Modified Files: src/lib/libc/gen: vis.c Log Message: Use 16x instead of 4x the amount of space since each wint_t can result in 4 bytes of 4 characters ("\ooo") each. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/lib/libc/gen/vis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.c diff -u src/lib/libc/gen/vis.c:1.73 src/lib/libc/gen/vis.c:1.74 --- src/lib/libc/gen/vis.c:1.73 Sat Apr 22 21:58:48 2017 +++ src/lib/libc/gen/vis.c Mon Nov 27 11:37:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.73 2017/04/23 01:58:48 christos Exp $ */ +/* $NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.73 2017/04/23 01:58:48 christos Exp $"); +__RCSID("$NetBSD: vis.c,v 1.74 2017/11/27 16:37:21 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef __FBSDID __FBSDID("$FreeBSD$"); @@ -432,10 +432,10 @@ istrsenvisx(char **mbdstp, size_t *dlen, mdst = NULL; if ((psrc = calloc(mbslength + 1, sizeof(*psrc))) == NULL) return -1; - if ((pdst = calloc((4 * mbslength) + 1, sizeof(*pdst))) == NULL) + if ((pdst = calloc((16 * mbslength) + 1, sizeof(*pdst))) == NULL) goto out; if (*mbdstp == NULL) { - if ((mdst = calloc((4 * mbslength) + 1, sizeof(*mdst))) == NULL) + if ((mdst = calloc((16 * mbslength) + 1, sizeof(*mdst))) == NULL) goto out; *mbdstp = mdst; } @@ -468,12 +468,13 @@ istrsenvisx(char **mbdstp, size_t *dlen, clen = 1; cerr = 1; } - if (clen == 0) + if (clen == 0) { /* * NUL in input gives 0 return value. process * as single NUL byte and keep going. */ clen = 1; + } /* Advance buffer character pointer. */ src++; /* Advance input pointer by number of bytes read. */
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 19:14:55 UTC 2017 Modified Files: src/lib/libc/gen: unvis.3 Log Message: Add missing functions from the SYNOPSIS to the NAME section To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libc/gen/unvis.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/unvis.3 diff -u src/lib/libc/gen/unvis.3:1.28 src/lib/libc/gen/unvis.3:1.29 --- src/lib/libc/gen/unvis.3:1.28 Mon Jul 3 21:32:49 2017 +++ src/lib/libc/gen/unvis.3 Tue Oct 24 19:14:55 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: unvis.3,v 1.28 2017/07/03 21:32:49 wiz Exp $ +.\" $NetBSD: unvis.3,v 1.29 2017/10/24 19:14:55 abhinav Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -34,7 +34,10 @@ .Os .Sh NAME .Nm unvis , -.Nm strunvis +.Nm strunvis , +.Nm strnunvis , +.Nm strunvisx , +.Nm strnunvisx .Nd decode a visual representation of characters .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 19:07:13 UTC 2017 Modified Files: src/lib/libc/gen: randomid.3 Log Message: Use commas at the right places in the NAME section To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libc/gen/randomid.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/randomid.3 diff -u src/lib/libc/gen/randomid.3:1.8 src/lib/libc/gen/randomid.3:1.9 --- src/lib/libc/gen/randomid.3:1.8 Mon Jul 3 21:32:49 2017 +++ src/lib/libc/gen/randomid.3 Tue Oct 24 19:07:12 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: randomid.3,v 1.8 2017/07/03 21:32:49 wiz Exp $ +.\" $NetBSD: randomid.3,v 1.9 2017/10/24 19:07:12 abhinav Exp $ .\" .\" Copyright (C) 2006 The NetBSD Foundation .\" All rights reserved. @@ -34,9 +34,9 @@ .Dt RANDOMID 3 .Os .Sh NAME -.Nm randomid +.Nm randomid , .Nm randomid_new , -.Nm randomid_delete , +.Nm randomid_delete .Nd provide pseudo-random data stream without repetitions .Sh SYNOPSIS .In sys/types.h
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 19:04:58 UTC 2017 Modified Files: src/lib/libc/gen: pwcache.3 Log Message: Add missing functions from the SYNOPSIS to the NAME section To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/pwcache.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/pwcache.3 diff -u src/lib/libc/gen/pwcache.3:1.17 src/lib/libc/gen/pwcache.3:1.18 --- src/lib/libc/gen/pwcache.3:1.17 Fri May 2 18:11:04 2008 +++ src/lib/libc/gen/pwcache.3 Tue Oct 24 19:04:58 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: pwcache.3,v 1.17 2008/05/02 18:11:04 martin Exp $ +.\" $NetBSD: pwcache.3,v 1.18 2017/10/24 19:04:58 abhinav Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -61,7 +61,11 @@ .Sh NAME .Nm pwcache , .Nm user_from_uid , -.Nm group_from_gid +.Nm uid_from_user , +.Nm pwcache_userdb , +.Nm group_from_gid , +.Nm gid_from_group , +.Nm pwcache_groupdb .Nd cache password and group entries .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 18:54:03 UTC 2017 Modified Files: src/lib/libc/gen: getgrouplist.3 Log Message: Remove trailing comma after last Nm entry in the NAME section To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/getgrouplist.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/getgrouplist.3 diff -u src/lib/libc/gen/getgrouplist.3:1.14 src/lib/libc/gen/getgrouplist.3:1.15 --- src/lib/libc/gen/getgrouplist.3:1.14 Fri May 2 18:11:04 2008 +++ src/lib/libc/gen/getgrouplist.3 Tue Oct 24 18:54:03 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: getgrouplist.3,v 1.14 2008/05/02 18:11:04 martin Exp $ +.\" $NetBSD: getgrouplist.3,v 1.15 2017/10/24 18:54:03 abhinav Exp $ .\" .\" Copyright (c) 2005 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -61,7 +61,7 @@ .Os .Sh NAME .Nm getgrouplist , -.Nm getgroupmembership , +.Nm getgroupmembership .Nd calculate group access list .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 18:50:46 UTC 2017 Modified Files: src/lib/libc/gen: getpass.3 Log Message: Add getpass_r and getpassfd to the NAME section as well. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libc/gen/getpass.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/getpass.3 diff -u src/lib/libc/gen/getpass.3:1.22 src/lib/libc/gen/getpass.3:1.23 --- src/lib/libc/gen/getpass.3:1.22 Sat Apr 14 10:34:29 2012 +++ src/lib/libc/gen/getpass.3 Tue Oct 24 18:50:46 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: getpass.3,v 1.22 2012/04/14 10:34:29 wiz Exp $ +.\" $NetBSD: getpass.3,v 1.23 2017/10/24 18:50:46 abhinav Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,9 @@ .Dt GETPASS 3 .Os .Sh NAME -.Nm getpass +.Nm getpass , +.Nm getpass_r , +.Nm getpassfd .Nd get a password .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Oct 24 18:42:06 UTC 2017 Modified Files: src/lib/libc/gen: cgetcap.3 Log Message: Fix typo: s/cexpandtc/csetexpandtc The synopsis and description mention only csetexpandtc function. nxr also only shows csetexpandtc while no matches for cexpandtc. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/lib/libc/gen/cgetcap.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/cgetcap.3 diff -u src/lib/libc/gen/cgetcap.3:1.8 src/lib/libc/gen/cgetcap.3:1.9 --- src/lib/libc/gen/cgetcap.3:1.8 Sun Apr 22 10:13:52 2012 +++ src/lib/libc/gen/cgetcap.3 Tue Oct 24 18:42:06 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: cgetcap.3,v 1.8 2012/04/22 10:13:52 wiz Exp $ +.\" $NetBSD: cgetcap.3,v 1.9 2017/10/24 18:42:06 abhinav Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -46,7 +46,7 @@ .Nm cgetfirst , .Nm cgetnext , .Nm cgetclose , -.Nm cexpandtc +.Nm csetexpandtc .Nd capability database access routines .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Wed Sep 27 18:55:50 UTC 2017 Modified Files: src/lib/libc/gen: isnan.3 Log Message: move VAX notes to CAVEATS, clarify. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/isnan.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/isnan.3 diff -u src/lib/libc/gen/isnan.3:1.2 src/lib/libc/gen/isnan.3:1.3 --- src/lib/libc/gen/isnan.3:1.2 Thu Mar 4 23:49:31 2004 +++ src/lib/libc/gen/isnan.3 Wed Sep 27 18:55:50 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: isnan.3,v 1.2 2004/03/04 23:49:31 wiz Exp $ +.\" $NetBSD: isnan.3,v 1.3 2017/09/27 18:55:50 maya Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -30,7 +30,7 @@ .\" From: @(#)isinf.3 8.2 (Berkeley) 1/29/94 .\" from: NetBSD: isinf.3,v 1.10 2003/08/07 16:42:52 agc Exp .\" -.Dd March 5, 2004 +.Dd September 27, 2017 .Dt ISNAN 3 .Os .Sh NAME @@ -52,12 +52,6 @@ is not-a-number An argument represented in a format wider than its semantic type is converted to its semantic type first. The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is a NaN. -.Ss VAX -NaNs are not supported. .Sh RETURN VALUES The .Fn isnan @@ -84,3 +78,8 @@ The .Fn isnan macro conforms to .St -isoC-99 . +.Sh CAVEATS +On VAX the +.Fn isnan +function always returns 0, +as the architecture doesn't support NaN.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Wed Sep 27 09:04:30 UTC 2017 Modified Files: src/lib/libc/gen: isinf.3 Log Message: Move VAX notes to CAVEATS, clarify that it just returns zero The VAX isinf implementation is in sys/arch/vax/include/math.h. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/isinf.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/isinf.3 diff -u src/lib/libc/gen/isinf.3:1.12 src/lib/libc/gen/isinf.3:1.13 --- src/lib/libc/gen/isinf.3:1.12 Thu Mar 4 23:47:56 2004 +++ src/lib/libc/gen/isinf.3 Wed Sep 27 09:04:30 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: isinf.3,v 1.12 2004/03/04 23:47:56 wiz Exp $ +.\" $NetBSD: isinf.3,v 1.13 2017/09/27 09:04:30 maya Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)isinf.3 8.2 (Berkeley) 1/29/94 .\" -.Dd March 5, 2004 +.Dd September 27, 2017 .Dt ISINF 3 .Os .Sh NAME @@ -50,12 +50,6 @@ is an infinity (positive or negative). An argument represented in a format wider than its semantic type is converted to its semantic type first. The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is an infinity. -.Ss VAX -Infinities are not supported. .Sh RETURN VALUES The .Fn isinf @@ -82,3 +76,8 @@ The .Fn isinf macro conforms to .St -isoC-99 . +.Sh CAVEATS +On VAX the +.Fn isinf +function always returns 0, +as the architecture doesn't have a representation for infinity.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Mon Sep 18 08:48:23 UTC 2017 Modified Files: src/lib/libc/gen: exec.3 Log Message: Remove superfluous Tn. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/lib/libc/gen/exec.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/exec.3 diff -u src/lib/libc/gen/exec.3:1.28 src/lib/libc/gen/exec.3:1.29 --- src/lib/libc/gen/exec.3:1.28 Sun Sep 17 11:45:10 2017 +++ src/lib/libc/gen/exec.3 Mon Sep 18 08:48:23 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: exec.3,v 1.28 2017/09/17 11:45:10 abhinav Exp $ +.\" $NetBSD: exec.3,v 1.29 2017/09/18 08:48:23 wiz Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -226,9 +226,7 @@ and .Fn execvpe when errors occur while attempting to execute the file is historic practice, but has not traditionally been documented and is not specified -by the -.Tn POSIX -standard. +by the POSIX standard. .Pp Traditionally, the functions .Fn execlp ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Sun Sep 17 11:45:10 UTC 2017 Modified Files: src/lib/libc/gen: exec.3 Log Message: Add execlpe and execvpe to the NAME section To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/lib/libc/gen/exec.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/exec.3 diff -u src/lib/libc/gen/exec.3:1.27 src/lib/libc/gen/exec.3:1.28 --- src/lib/libc/gen/exec.3:1.27 Sat Dec 10 14:13:29 2016 +++ src/lib/libc/gen/exec.3 Sun Sep 17 11:45:10 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: exec.3,v 1.27 2016/12/10 14:13:29 rin Exp $ +.\" $NetBSD: exec.3,v 1.28 2017/09/17 11:45:10 abhinav Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -35,10 +35,12 @@ .Sh NAME .Nm execl , .Nm execlp , +.Nm execlpe , .Nm execle , .Nm exect , .Nm execv , -.Nm execvp +.Nm execvp , +.Nm execvpe .Nd execute a file .Sh LIBRARY .Lb libc
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Sun Sep 10 10:12:43 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.16 src/lib/libc/gen/devname.3:1.17 --- src/lib/libc/gen/devname.3:1.16 Sun Sep 10 10:12:21 2017 +++ src/lib/libc/gen/devname.3 Sun Sep 10 10:12:43 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.16 2017/09/10 10:12:21 wiz Exp $ +.\" $NetBSD: devname.3,v 1.17 2017/09/10 10:12:43 wiz Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -105,7 +105,7 @@ Device database file. .Sh ERRORS The .Fn devname_r -function my fail if: +function may fail if: .Bl -tag -width Er .It Bq Er ENOENT The corresponding device does not exist.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Sun Sep 10 10:12:21 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Sort sections. Make error descriptions complete sentences. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.15 src/lib/libc/gen/devname.3:1.16 --- src/lib/libc/gen/devname.3:1.15 Sun Sep 10 00:49:40 2017 +++ src/lib/libc/gen/devname.3 Sun Sep 10 10:12:21 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.15 2017/09/10 00:49:40 kre Exp $ +.\" $NetBSD: devname.3,v 1.16 2017/09/10 10:12:21 wiz Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -97,20 +97,20 @@ If an error occurs will return an error number from .In sys/errno.h indicating what went wrong. +.Sh FILES +.Bl -tag -width /var/run/dev.cdb -compact +.It Pa /var/run/dev.cdb +Device database file. +.El .Sh ERRORS The .Fn devname_r function my fail if: .Bl -tag -width Er .It Bq Er ENOENT -the corresponding device does not exist +The corresponding device does not exist. .It Bq Er ERANGE -the passed buffer length is too short -.El -.Sh FILES -.Bl -tag -width /var/run/dev.cdb -compact -.It Pa /var/run/dev.cdb -Device database file. +The passed buffer length is too short. .El .Sh SEE ALSO .Xr stat 2 ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Sun Sep 10 00:49:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Fix a typo, and some wording improvements. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.14 src/lib/libc/gen/devname.3:1.15 --- src/lib/libc/gen/devname.3:1.14 Sat Sep 9 18:45:04 2017 +++ src/lib/libc/gen/devname.3 Sun Sep 10 00:49:40 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.14 2017/09/09 18:45:04 kamil Exp $ +.\" $NetBSD: devname.3,v 1.15 2017/09/10 00:49:40 kre Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -48,8 +48,8 @@ .Sh DESCRIPTION The .Fn devname -function returns a pointer to the static buffer with the name of the block or character -device in +function returns a pointer to the static buffer with the name of the +block or character device in .Dq Pa /dev with a device number of .Fa dev , @@ -63,7 +63,7 @@ is returned. .Pp The .Fn devname_r -function is a reentrand and thread-safe version of +function is a reentrant and thread-safe version of .Fn devname . This function returns the device name by copying it into the .Fa path @@ -88,10 +88,15 @@ will return .Pp If successful, .Fn devname_r -places a nul-terminated string containing the name of the device and returns 0. -If error occurs +places a nul-terminated string containing the name of the device in +the buffer pointed to by +.Ar path +and returns 0. +If an error occurs .Fn devname_r -will return error number indicating what went wrong. +will return an error number from +.In sys/errno.h +indicating what went wrong. .Sh ERRORS The .Fn devname_r
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:45:04 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Remove the BUGS section from devname(3) devname(3) does not report type of error on purpose. Suggested by To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.13 src/lib/libc/gen/devname.3:1.14 --- src/lib/libc/gen/devname.3:1.13 Sat Sep 9 18:00:39 2017 +++ src/lib/libc/gen/devname.3 Sat Sep 9 18:45:04 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.13 2017/09/09 18:00:39 kamil Exp $ +.\" $NetBSD: devname.3,v 1.14 2017/09/09 18:45:04 kamil Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -94,10 +94,8 @@ If error occurs will return error number indicating what went wrong. .Sh ERRORS The -.Fn devname -and .Fn devname_r -functions my fail if: +function my fail if: .Bl -tag -width Er .It Bq Er ENOENT the corresponding device does not exist @@ -122,7 +120,3 @@ The .Fn devname_r function first appeared in .Nx 6.0 . -.Sh BUGS -The -.Fn devname -function does not set errno on failure.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:00:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Document devname_r(3) in devname(3). Improve clarity of devname(3) mentioning that it returns a pointer to the buffer pointer. This approach is not thread-safe and not reentrant. Not that devname(3) does not set errno on failure and document it as a bug. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.12 src/lib/libc/gen/devname.3:1.13 --- src/lib/libc/gen/devname.3:1.12 Sun Jun 3 21:42:46 2012 +++ src/lib/libc/gen/devname.3 Sat Sep 9 18:00:39 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.12 2012/06/03 21:42:46 joerg Exp $ +.\" $NetBSD: devname.3,v 1.13 2017/09/09 18:00:39 kamil Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,11 +29,12 @@ .\" .\" @(#)devname.3 8.2 (Berkeley) 4/29/95 .\" -.Dd June 3, 2012 +.Dd September 9, 2017 .Dt DEVNAME 3 .Os .Sh NAME -.Nm devname +.Nm devname , +.Nm devname_r .Nd get device name .Sh LIBRARY .Lb libc @@ -42,10 +43,12 @@ .In sys/stat.h .Ft char * .Fn devname "dev_t dev" "mode_t type" +.Ft int +.Fn devname_r "dev_t dev" "mode_t type" "char *path" "size_t len" .Sh DESCRIPTION The .Fn devname -function returns a pointer to the name of the block or character +function returns a pointer to the static buffer with the name of the block or character device in .Dq Pa /dev with a device number of @@ -58,9 +61,49 @@ available, .Dv NULL is returned. .Pp +The +.Fn devname_r +function is a reentrand and thread-safe version of +.Fn devname . +This function returns the device name by copying it into the +.Fa path +argument with up to +.Fa len +characters. +The +.Fa path +argument is always nul-terminated. +.Pp The traditional display for applications when no device is found is the string .Dq ?? . +.Sh RETURN VALUES +If successful, +.Fn devname +returns a pointer to a nul-terminated string containing the name of the device. +If an error occurs +.Fa devname +will return +.Dv NULL . +.Pp +If successful, +.Fn devname_r +places a nul-terminated string containing the name of the device and returns 0. +If error occurs +.Fn devname_r +will return error number indicating what went wrong. +.Sh ERRORS +The +.Fn devname +and +.Fn devname_r +functions my fail if: +.Bl -tag -width Er +.It Bq Er ENOENT +the corresponding device does not exist +.It Bq Er ERANGE +the passed buffer length is too short +.El .Sh FILES .Bl -tag -width /var/run/dev.cdb -compact .It Pa /var/run/dev.cdb @@ -74,3 +117,12 @@ The .Nm devname function call appeared in .Bx 4.4 . +.Pp +The +.Fn devname_r +function first appeared in +.Nx 6.0 . +.Sh BUGS +The +.Fn devname +function does not set errno on failure.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Sat Aug 5 20:22:29 UTC 2017 Modified Files: src/lib/libc/gen: vis.3 Log Message: Remove superfluous Pp. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/lib/libc/gen/vis.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.3 diff -u src/lib/libc/gen/vis.3:1.48 src/lib/libc/gen/vis.3:1.49 --- src/lib/libc/gen/vis.3:1.48 Fri Aug 4 01:06:22 2017 +++ src/lib/libc/gen/vis.3 Sat Aug 5 20:22:29 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vis.3,v 1.48 2017/08/04 01:06:22 ginsbach Exp $ +.\" $NetBSD: vis.3,v 1.49 2017/08/05 20:22:29 wiz Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -374,7 +374,6 @@ space. .It Dv \e240 Represents Meta-space. .El -.Pp .It Dv VIS_CSTYLE Use C-style backslash sequences to represent standard non-printable characters.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: ginsbach Date: Fri Aug 4 01:06:22 UTC 2017 Modified Files: src/lib/libc/gen: vis.3 Log Message: There are more than four types of encoding. The combination of VIS_CSTYLE | VIS_OCTAL is different from either separately. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/lib/libc/gen/vis.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.3 diff -u src/lib/libc/gen/vis.3:1.47 src/lib/libc/gen/vis.3:1.48 --- src/lib/libc/gen/vis.3:1.47 Sun Apr 23 13:23:02 2017 +++ src/lib/libc/gen/vis.3 Fri Aug 4 01:06:22 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vis.3,v 1.47 2017/04/23 13:23:02 christos Exp $ +.\" $NetBSD: vis.3,v 1.48 2017/08/04 01:06:22 ginsbach Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -311,7 +311,7 @@ warning on the use of the .Dv VIS_NOSLASH flag below). .Pp -There are four forms of encoding. +There are six forms of encoding. All forms use the backslash character .Ql \e to introduce a special @@ -403,6 +403,9 @@ If .Fa nextc is an octal digit, the latter representation is used to avoid ambiguity. +.Pp +Non-printable characters without C-style +backslash sequences use the default representation. .It Dv VIS_OCTAL Use a three digit octal sequence. The form is @@ -410,6 +413,11 @@ The form is where .Em d represents an octal digit. +.It Dv VIS_CSTYLE \&| Dv VIS_OCTAL +Same as +.Dv VIS_CSTYLE +except that non-printable characters without C-style +backslash sequences use a three digit octal sequence. .It Dv VIS_HTTPSTYLE Use URI encoding as described in RFC 1738. The form is
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon May 15 16:09:09 UTC 2017 Modified Files: src/lib/libc/gen: assert.c Log Message: Don't make assert use stdio; saves >100K on an empty static binary. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/assert.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/assert.c diff -u src/lib/libc/gen/assert.c:1.17 src/lib/libc/gen/assert.c:1.18 --- src/lib/libc/gen/assert.c:1.17 Mon Jun 25 18:32:43 2012 +++ src/lib/libc/gen/assert.c Mon May 15 12:09:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $ */ +/* $NetBSD: assert.c,v 1.18 2017/05/15 16:09:09 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $"); +__RCSID("$NetBSD: assert.c,v 1.18 2017/05/15 16:09:09 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -44,19 +44,31 @@ __RCSID("$NetBSD: assert.c,v 1.17 2012/0 #include #include #include +#include #include +#include "extern.h" -void -__assert13(const char *file, int line, const char *function, -const char *failedexpr) +static int +fmtassert(char *buf, size_t len, const char *file, int line, +const char *function, const char *failedexpr) { - - (void)fprintf(stderr, + return snprintf_ss(buf, len, "assertion \"%s\" failed: file \"%s\", line %d%s%s%s\n", failedexpr, file, line, function ? ", function \"" : "", function ? function : "", function ? "\"" : ""); +} + +void +__assert13(const char *file, int line, const char *function, +const char *failedexpr) +{ + char buf[1024]; + int l = fmtassert(buf, sizeof(buf), file, line, function, failedexpr); + if (l < 0) + abort(); + (void)write(STDERR_FILENO, buf, (size_t)l); abort(); /* NOTREACHED */ } @@ -113,16 +125,19 @@ __diagassert13(const char *file, int lin } } - snprintf(buf, sizeof(buf), - "assertion \"%s\" failed: file \"%s\", line %d%s%s%s", - failedexpr, file, line, - function ? ", function \"" : "", - function ? function : "", - function ? "\"" : ""); - if (diagassert_flags & DIAGASSERT_STDERR) - (void)fprintf(stderr, "%s: %s\n", getprogname(), buf); - if (diagassert_flags & DIAGASSERT_SYSLOG) - syslog(LOG_DEBUG | LOG_USER, "%s", buf); + fmtassert(buf, sizeof(buf), file, line, function, failedexpr); + if (diagassert_flags & DIAGASSERT_STDERR) { + char ebuf[1024]; + int l = snprintf_ss(ebuf, sizeof(ebuf), "%s: %s\n", + getprogname(), buf); + if (l == -1) + abort(); + (void)write(STDERR_FILENO, ebuf, (size_t)l); + } + if (diagassert_flags & DIAGASSERT_SYSLOG) { + struct syslog_data sdata = SYSLOG_DATA_INIT; + syslog_ss(LOG_DEBUG | LOG_USER, , "%s", buf); + } if (diagassert_flags & DIAGASSERT_ABORT) abort(); }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Sun May 14 12:35:47 UTC 2017 Modified Files: src/lib/libc/gen: signalname.3 Log Message: Formatting and punctuation improvements. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/signalname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/signalname.3 diff -u src/lib/libc/gen/signalname.3:1.1 src/lib/libc/gen/signalname.3:1.2 --- src/lib/libc/gen/signalname.3:1.1 Tue May 9 11:14:16 2017 +++ src/lib/libc/gen/signalname.3 Sun May 14 12:35:46 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: signalname.3,v 1.1 2017/05/09 11:14:16 kre Exp $ +.\" $NetBSD: signalname.3,v 1.2 2017/05/14 12:35:46 wiz Exp $ .\" .\" Available to all and sundry, without restriction on use, or other .\" limitations, and without fee. Also without any warranty of fitness @@ -20,8 +20,8 @@ .Dt SIGNALNAME 3 .Os .Sh NAME -.Nm signalname -.Nm signalnumber +.Nm signalname , +.Nm signalnumber , .Nm signalnext .Nd convert between signal numbers and names .Sh LIBRARY @@ -43,16 +43,21 @@ and returns the name of that signal. The name returned is locale independent, and can be the string representation of one of the signal names from -.In signal.h -such as SIGHUP, SIGSTOP, SIGKILL, +.In signal.h +such as +.Dv SIGHUP , +.Dv SIGSTOP , +.Dv SIGKILL , or some similar name, but does not contain the leading -.Dq SIG +.Dq Dv SIG prefix. .Pp The return value of .Fn signalname -is NULL if +is +.Dv NULL +if .Fa sig does not represent a valid signal number, or if the signal number given has no name. @@ -66,7 +71,7 @@ The .Fa name is handled in a case-insensitive manner. Any leading -.Dq SIG +.Dq Dv SIG prefix in .Fa name is ignored. @@ -90,7 +95,7 @@ The .Fn signalnext function returns minus one (\-1) on error, if the given signal .Fa sig -is neither a valid signal number, nor zero. +is neither a valid signal number nor zero. It returns zero when the input signal number, .Fa sig , is the biggest available signal number. @@ -126,7 +131,7 @@ is invalid. .Sh HISTORY The .Fn signalname , -.Fn signalnext +.Fn signalnext , and .Fn signalnumber functions first appeared in
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Mon May 8 14:42:16 UTC 2017 Modified Files: src/lib/libc/gen: glob.c Log Message: use the symbolic M_ALL and trim with M_MASK To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/lib/libc/gen/glob.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/glob.c diff -u src/lib/libc/gen/glob.c:1.37 src/lib/libc/gen/glob.c:1.38 --- src/lib/libc/gen/glob.c:1.37 Wed Apr 26 10:56:54 2017 +++ src/lib/libc/gen/glob.c Mon May 8 10:42:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: glob.c,v 1.37 2017/04/26 14:56:54 christos Exp $ */ +/* $NetBSD: glob.c,v 1.38 2017/05/08 14:42:16 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; #else -__RCSID("$NetBSD: glob.c,v 1.37 2017/04/26 14:56:54 christos Exp $"); +__RCSID("$NetBSD: glob.c,v 1.38 2017/05/08 14:42:16 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -958,7 +958,7 @@ match(const Char *name, const Char *pat, nameEnd = name; switch (c & M_MASK) { case M_ALL: - while (pat[1] == '*') pat++; + while ((pat[1] & M_MASK) == M_ALL) pat++; patNext = pat; nameNext = name + 1; pat++;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Wed Apr 26 14:56:54 UTC 2017 Modified Files: src/lib/libc/gen: glob.c Log Message: Switch from a recursive pattern matching algorithm to handle '*' to a backtracking one. Avoids DoS attacks with patterns "a*a*a*a*a*...b" matching against "..." https://research.swtch.com/glob To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libc/gen/glob.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/glob.c diff -u src/lib/libc/gen/glob.c:1.36 src/lib/libc/gen/glob.c:1.37 --- src/lib/libc/gen/glob.c:1.36 Sun Sep 4 14:27:08 2016 +++ src/lib/libc/gen/glob.c Wed Apr 26 10:56:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: glob.c,v 1.36 2016/09/04 18:27:08 joerg Exp $ */ +/* $NetBSD: glob.c,v 1.37 2017/04/26 14:56:54 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; #else -__RCSID("$NetBSD: glob.c,v 1.36 2016/09/04 18:27:08 joerg Exp $"); +__RCSID("$NetBSD: glob.c,v 1.37 2017/04/26 14:56:54 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -936,39 +936,45 @@ nospace: /* - * pattern matching function for filenames. Each occurrence of the * - * pattern causes a recursion level. + * pattern matching function for filenames. */ static int match(const Char *name, const Char *pat, const Char *patend) { int ok, negate_range; Char c, k; + const Char *patNext, *nameNext, *nameStart, *nameEnd; _DIAGASSERT(name != NULL); _DIAGASSERT(pat != NULL); _DIAGASSERT(patend != NULL); - - while (pat < patend) { - c = *pat++; + patNext = pat; + nameStart = nameNext = name; + nameEnd = NULL; + + while (pat < patend || *name) { + c = *pat; + if (*name == EOS) + nameEnd = name; switch (c & M_MASK) { case M_ALL: - while (pat < patend && (*pat & M_MASK) == M_ALL) -pat++; /* eat consecutive '*' */ - if (pat == patend) -return 1; - for (; !match(name, pat, patend); name++) -if (*name == EOS) - return 0; - return 1; + while (pat[1] == '*') pat++; + patNext = pat; + nameNext = name + 1; + pat++; + continue; case M_ONE: - if (*name++ == EOS) -return 0; - break; + if (*name == EOS) +break; + pat++; + name++; + continue; case M_SET: ok = 0; - if ((k = *name++) == EOS) -return 0; + if ((k = *name) == EOS) +break; + pat++; + name++; if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) ++pat; while (((c = *pat++) & M_MASK) != M_END) @@ -979,15 +985,24 @@ match(const Char *name, const Char *pat, } else if (c == k) ok = 1; if (ok == negate_range) -return 0; - break; +break; + continue; default: - if (*name++ != c) -return 0; - break; + if (*name != c) +break; + pat++; + name++; + continue; } + if (nameNext != nameStart + && (nameEnd == NULL || nameNext <= nameEnd)) { + pat = patNext; + name = nameNext; + continue; + } + return 0; } - return *name == EOS; + return 1; } /* Free allocated data belonging to a glob_t structure. */
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Apr 23 13:23:02 UTC 2017 Modified Files: src/lib/libc/gen: vis.3 Log Message: fix typo (Leonardo Taccari) To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/lib/libc/gen/vis.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.3 diff -u src/lib/libc/gen/vis.3:1.46 src/lib/libc/gen/vis.3:1.47 --- src/lib/libc/gen/vis.3:1.46 Sat Apr 22 21:58:48 2017 +++ src/lib/libc/gen/vis.3 Sun Apr 23 09:23:02 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vis.3,v 1.46 2017/04/23 01:58:48 christos Exp $ +.\" $NetBSD: vis.3,v 1.47 2017/04/23 13:23:02 christos Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -242,7 +242,7 @@ except space, tab, and newline are encod The following flags alter this: .Bl -tag -width VIS_WHITEX -.It Dv VIS_DW +.It Dv VIS_DQ Also encode double quotes .It Dv VIS_GLOB Also encode the magic characters
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Apr 23 01:58:48 UTC 2017 Modified Files: src/lib/libc/gen: vis.3 vis.c Log Message: Add VIS_DQ (for OpenBSD compat) To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/lib/libc/gen/vis.3 cvs rdiff -u -r1.72 -r1.73 src/lib/libc/gen/vis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.3 diff -u src/lib/libc/gen/vis.3:1.45 src/lib/libc/gen/vis.3:1.46 --- src/lib/libc/gen/vis.3:1.45 Wed Jun 8 11:00:04 2016 +++ src/lib/libc/gen/vis.3 Sat Apr 22 21:58:48 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vis.3,v 1.45 2016/06/08 15:00:04 wiz Exp $ +.\" $NetBSD: vis.3,v 1.46 2017/04/23 01:58:48 christos Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)vis.3 8.1 (Berkeley) 6/9/93 .\" -.Dd January 14, 2015 +.Dd April 22, 2017 .Dt VIS 3 .Os .Sh NAME @@ -242,6 +242,8 @@ except space, tab, and newline are encod The following flags alter this: .Bl -tag -width VIS_WHITEX +.It Dv VIS_DW +Also encode double quotes .It Dv VIS_GLOB Also encode the magic characters .Ql ( * , Index: src/lib/libc/gen/vis.c diff -u src/lib/libc/gen/vis.c:1.72 src/lib/libc/gen/vis.c:1.73 --- src/lib/libc/gen/vis.c:1.72 Sun Feb 12 17:37:49 2017 +++ src/lib/libc/gen/vis.c Sat Apr 22 21:58:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $ */ +/* $NetBSD: vis.c,v 1.73 2017/04/23 01:58:48 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $"); +__RCSID("$NetBSD: vis.c,v 1.73 2017/04/23 01:58:48 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef __FBSDID __FBSDID("$FreeBSD$"); @@ -377,6 +377,7 @@ makeextralist(int flags, const char *src if (flags & VIS_SP) *d++ = L' '; if (flags & VIS_TAB) *d++ = L'\t'; if (flags & VIS_NL) *d++ = L'\n'; + if (flags & VIS_DQ) *d++ = L'"'; if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\'; *d = L'\0';
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Tue Apr 18 12:34:07 UTC 2017 Modified Files: src/lib/libc/gen: xsyslog.c Log Message: always initialize iovcnt from clang static analyzer To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/xsyslog.c diff -u src/lib/libc/gen/xsyslog.c:1.4 src/lib/libc/gen/xsyslog.c:1.5 --- src/lib/libc/gen/xsyslog.c:1.4 Wed Mar 22 19:36:04 2017 +++ src/lib/libc/gen/xsyslog.c Tue Apr 18 12:34:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xsyslog.c,v 1.4 2017/03/22 19:36:04 kre Exp $ */ +/* $NetBSD: xsyslog.c,v 1.5 2017/04/18 12:34:07 maya Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: xsyslog.c,v 1.4 2017/03/22 19:36:04 kre Exp $"); +__RCSID("$NetBSD: xsyslog.c,v 1.5 2017/04/18 12:34:07 maya Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -154,7 +154,7 @@ _vxsyslogp_r(int pri, struct syslog_fun struct iovec iov[7]; /* prog + [ + pid + ]: + fmt + crlf */ int opened, iovcnt; - opened = 0; + iovcnt = opened = 0; #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID /* Check for invalid bits. */ @@ -205,7 +205,6 @@ _vxsyslogp_r(int pri, struct syslog_fun (*fun->unlock)(data); if (data->log_stat & (LOG_PERROR|LOG_CONS)) { - iovcnt = 0; iov[iovcnt].iov_base = p; iov[iovcnt].iov_len = prlen - 1; iovcnt++;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Thu Apr 13 17:45:56 UTC 2017 Modified Files: src/lib/libc/gen: humanize_number.c Log Message: Fix out of bounds read for very large numbers (pointed out by Brooks Davis) https://svnweb.freebsd.org/changeset/base/316766 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gen/humanize_number.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/humanize_number.c diff -u src/lib/libc/gen/humanize_number.c:1.16 src/lib/libc/gen/humanize_number.c:1.17 --- src/lib/libc/gen/humanize_number.c:1.16 Sat Mar 17 16:01:14 2012 +++ src/lib/libc/gen/humanize_number.c Thu Apr 13 13:45:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: humanize_number.c,v 1.16 2012/03/17 20:01:14 christos Exp $ */ +/* $NetBSD: humanize_number.c,v 1.17 2017/04/13 17:45:56 christos Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: humanize_number.c,v 1.16 2012/03/17 20:01:14 christos Exp $"); +__RCSID("$NetBSD: humanize_number.c,v 1.17 2017/04/13 17:45:56 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -76,9 +76,9 @@ humanize_number(char *buf, size_t len, i } #define SCALE2PREFIX(scale) ([(scale) << 1]) - maxscale = 7; + maxscale = 6; - if ((size_t)scale >= maxscale && + if ((size_t)scale > maxscale && (scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0) return (-1);
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Thu Mar 23 12:31:57 UTC 2017 Modified Files: src/lib/libc/gen: syslog.3 Log Message: Remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/lib/libc/gen/syslog.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/syslog.3 diff -u src/lib/libc/gen/syslog.3:1.31 src/lib/libc/gen/syslog.3:1.32 --- src/lib/libc/gen/syslog.3:1.31 Wed Mar 22 17:52:36 2017 +++ src/lib/libc/gen/syslog.3 Thu Mar 23 12:31:57 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: syslog.3,v 1.31 2017/03/22 17:52:36 roy Exp $ +.\" $NetBSD: syslog.3,v 1.32 2017/03/23 12:31:57 wiz Exp $ .\" $OpenBSD: syslog.3,v 1.25 2005/07/22 03:16:58 jaredy Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 @@ -307,7 +307,7 @@ instantiations of daemons. (This PID is placed within brackets between the ident and the message.) .It Dv LOG_PTRIM -Trim anything syslog added to the message before writing to +Trim anything syslog added to the message before writing to standard error output. .El .Pp
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Wed Mar 22 19:36:04 UTC 2017 Modified Files: src/lib/libc/gen: xsyslog.c Log Message: Unbreak build, init variable (not a false alarm for this one.) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/xsyslog.c diff -u src/lib/libc/gen/xsyslog.c:1.3 src/lib/libc/gen/xsyslog.c:1.4 --- src/lib/libc/gen/xsyslog.c:1.3 Wed Mar 22 17:52:36 2017 +++ src/lib/libc/gen/xsyslog.c Wed Mar 22 19:36:04 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xsyslog.c,v 1.3 2017/03/22 17:52:36 roy Exp $ */ +/* $NetBSD: xsyslog.c,v 1.4 2017/03/22 19:36:04 kre Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: xsyslog.c,v 1.3 2017/03/22 17:52:36 roy Exp $"); +__RCSID("$NetBSD: xsyslog.c,v 1.4 2017/03/22 19:36:04 kre Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -154,6 +154,8 @@ _vxsyslogp_r(int pri, struct syslog_fun struct iovec iov[7]; /* prog + [ + pid + ]: + fmt + crlf */ int opened, iovcnt; + opened = 0; + #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID /* Check for invalid bits. */ if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
CVS commit: src/lib/libc/gen
Module Name:src Committed By: maya Date: Thu Mar 9 11:39:41 UTC 2017 Modified Files: src/lib/libc/gen: extattr.c Log Message: Remove redundant null check before free. it is safe to free(NULL) While here, clear up odd whitespace issue. NFC To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gen/extattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/extattr.c diff -u src/lib/libc/gen/extattr.c:1.4 src/lib/libc/gen/extattr.c:1.5 --- src/lib/libc/gen/extattr.c:1.4 Tue Mar 13 21:13:34 2012 +++ src/lib/libc/gen/extattr.c Thu Mar 9 11:39:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: extattr.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */ +/* $NetBSD: extattr.c,v 1.5 2017/03/09 11:39:41 maya Exp $ */ /*- * Copyright (c) 2001 Robert N. M. Watson @@ -32,7 +32,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: extattr.c,v 1.4 2012/03/13 21:13:34 christos Exp $"); +__RCSID("$NetBSD: extattr.c,v 1.5 2017/03/09 11:39:41 maya Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -150,7 +150,7 @@ extattr_copy_fd(int from_fd, int to_fd, } if ((vlen = extattr_get_fd(from_fd, namespace, aname, - aval, (size_t)vlen)) == -1) + aval, (size_t)vlen)) == -1) goto out; if (extattr_set_fd(to_fd, namespace, aname, @@ -160,12 +160,9 @@ extattr_copy_fd(int from_fd, int to_fd, error = 0; out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - + free(aval); + free(alist); + return error; } @@ -222,7 +219,8 @@ extattr_copy_file(const char *from, cons maxvlen = vlen; } - if ((vlen = extattr_get_file(from, namespace, aname, aval, (size_t)vlen)) == -1) + if ((vlen = extattr_get_file(from, namespace, aname, + aval, (size_t)vlen)) == -1) goto out; if (extattr_set_file(to, namespace, aname, @@ -232,12 +230,9 @@ extattr_copy_file(const char *from, cons error = 0; out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - + free(aval); + free(alist); + return error; } @@ -305,12 +300,9 @@ extattr_copy_link(const char *from, cons error = 0; out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - + free(aval); + free(alist); + return error; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: pgoyette Date: Mon Mar 6 09:24:09 UTC 2017 Modified Files: src/lib/libc/gen: realpath.3 Log Message: Improve grammar. Pointed out by Timo Buhrmester on netbsd-docs list. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/lib/libc/gen/realpath.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/realpath.3 diff -u src/lib/libc/gen/realpath.3:1.18 src/lib/libc/gen/realpath.3:1.19 --- src/lib/libc/gen/realpath.3:1.18 Fri May 24 09:35:11 2013 +++ src/lib/libc/gen/realpath.3 Mon Mar 6 09:24:09 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: realpath.3,v 1.18 2013/05/24 09:35:11 wiz Exp $ +.\" $NetBSD: realpath.3,v 1.19 2017/03/06 09:24:09 pgoyette Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -89,7 +89,7 @@ If an error occurs, .Fn realpath returns .Dv NULL , -and +and if .Fa resolvedname was not allocated by .Fn realpath ,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Feb 21 19:53:20 UTC 2017 Modified Files: src/lib/libc/gen: popen.3 Log Message: Use Fn for function name. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libc/gen/popen.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/popen.3 diff -u src/lib/libc/gen/popen.3:1.20 src/lib/libc/gen/popen.3:1.21 --- src/lib/libc/gen/popen.3:1.20 Wed Jan 21 08:35:31 2015 +++ src/lib/libc/gen/popen.3 Tue Feb 21 19:53:20 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: popen.3,v 1.20 2015/01/21 08:35:31 wiz Exp $ +.\" $NetBSD: popen.3,v 1.21 2017/02/21 19:53:20 abhinav Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -57,15 +57,15 @@ a process by creating an IPC connection, forking, and invoking the shell. Historically, -.Nm popen +.Fn popen was implemented with a unidirectional pipe; hence many implementations of -.Nm popen +.Fn popen only allow the .Fa type argument to specify reading or writing, not both. Since -.Nm popen +.Fn popen is now implemented using sockets, the .Fa type may request a bidirectional data flow.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Tue Feb 21 18:22:15 UTC 2017 Modified Files: src/lib/libc/gen: syslog.3 Log Message: Fix spelling of "parenthesis". To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/syslog.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/syslog.3 diff -u src/lib/libc/gen/syslog.3:1.29 src/lib/libc/gen/syslog.3:1.30 --- src/lib/libc/gen/syslog.3:1.29 Mon Jul 25 19:42:50 2011 +++ src/lib/libc/gen/syslog.3 Tue Feb 21 18:22:15 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: syslog.3,v 1.29 2011/07/25 19:42:50 njoly Exp $ +.\" $NetBSD: syslog.3,v 1.30 2017/02/21 18:22:15 abhinav Exp $ .\" $OpenBSD: syslog.3,v 1.25 2005/07/22 03:16:58 jaredy Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 @@ -511,7 +511,7 @@ A must only contain up to 32 ASCII characters. A .Fa sdfmt -has strict rules for paranthesis and character quoting. +has strict rules for parenthesis and character quoting. If the .Fa msgfmt contains UTF-8 characters, then it has to start with a Byte Order Mark.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Feb 12 22:37:49 UTC 2017 Modified Files: src/lib/libc/gen: vis.c Log Message: fix off-by-one, found by asan. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/lib/libc/gen/vis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/vis.c diff -u src/lib/libc/gen/vis.c:1.71 src/lib/libc/gen/vis.c:1.72 --- src/lib/libc/gen/vis.c:1.71 Thu Jan 14 15:41:23 2016 +++ src/lib/libc/gen/vis.c Sun Feb 12 17:37:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $ */ +/* $NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -57,7 +57,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $"); +__RCSID("$NetBSD: vis.c,v 1.72 2017/02/12 22:37:49 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef __FBSDID __FBSDID("$FreeBSD$"); @@ -405,6 +405,14 @@ istrsenvisx(char **mbdstp, size_t *dlen, _DIAGASSERT(mbsrc != NULL || mblength == 0); _DIAGASSERT(mbextra != NULL); + mbslength = (ssize_t)mblength; + /* + * When inputing a single character, must also read in the + * next character for nextc, the look-ahead character. + */ + if (mbslength == 1) + mbslength++; + /* * Input (mbsrc) is a char string considered to be multibyte * characters. The input loop will read this string pulling @@ -421,12 +429,12 @@ istrsenvisx(char **mbdstp, size_t *dlen, /* Allocate space for the wide char strings */ psrc = pdst = extra = NULL; mdst = NULL; - if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL) + if ((psrc = calloc(mbslength + 1, sizeof(*psrc))) == NULL) return -1; - if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL) + if ((pdst = calloc((4 * mbslength) + 1, sizeof(*pdst))) == NULL) goto out; if (*mbdstp == NULL) { - if ((mdst = calloc((4 * mblength) + 1, sizeof(*mdst))) == NULL) + if ((mdst = calloc((4 * mbslength) + 1, sizeof(*mdst))) == NULL) goto out; *mbdstp = mdst; } @@ -449,13 +457,6 @@ istrsenvisx(char **mbdstp, size_t *dlen, * stop at NULs because we may be processing a block of data * that includes NULs. */ - mbslength = (ssize_t)mblength; - /* - * When inputing a single character, must also read in the - * next character for nextc, the look-ahead character. - */ - if (mbslength == 1) - mbslength++; while (mbslength > 0) { /* Convert one multibyte character to wchar_t. */ if (!cerr) @@ -481,6 +482,7 @@ istrsenvisx(char **mbdstp, size_t *dlen, } len = src - psrc; src = psrc; + /* * In the single character input case, we will have actually * processed two characters, c and nextc. Reset len back to
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sun Jan 15 16:41:39 UTC 2017 Modified Files: src/lib/libc/gen: syslog_ss.c Log Message: fix *syslog_ss* To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/gen/syslog_ss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/syslog_ss.c diff -u src/lib/libc/gen/syslog_ss.c:1.2 src/lib/libc/gen/syslog_ss.c:1.3 --- src/lib/libc/gen/syslog_ss.c:1.2 Wed Jan 11 20:58:39 2017 +++ src/lib/libc/gen/syslog_ss.c Sun Jan 15 11:41:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog_ss.c,v 1.2 2017/01/12 01:58:39 christos Exp $ */ +/* $NetBSD: syslog_ss.c,v 1.3 2017/01/15 16:41:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: syslog_ss.c,v 1.2 2017/01/12 01:58:39 christos Exp $"); +__RCSID("$NetBSD: syslog_ss.c,v 1.3 2017/01/15 16:41:39 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -80,7 +80,7 @@ syslog_ss(int pri, struct syslog_data *d va_list ap; va_start(ap, fmt); - _vxsyslogp_r(pri, NULL, data, NULL, NULL, fmt, ap); + _vxsyslogp_r(pri, &_syslog_ss_fun, data, NULL, NULL, fmt, ap); va_end(ap); } @@ -91,19 +91,19 @@ syslogp_ss(int pri, struct syslog_data * va_list ap; va_start(ap, msgfmt); - _vxsyslogp_r(pri, NULL, data, msgid, sdfmt, msgfmt, ap); + _vxsyslogp_r(pri, &_syslog_ss_fun, data, msgid, sdfmt, msgfmt, ap); va_end(ap); } void vsyslog_ss(int pri, struct syslog_data *data, const char *fmt, va_list ap) { - _vxsyslogp_r(pri, NULL, data, NULL, NULL, fmt, ap); + _vxsyslogp_r(pri, &_syslog_ss_fun, data, NULL, NULL, fmt, ap); } void vsyslogp_ss(int pri, struct syslog_data *data, const char *msgid, const char *sdfmt, const char *msgfmt, va_list ap) { - _vxsyslogp_r(pri, NULL, data, msgid, sdfmt, msgfmt, ap); + _vxsyslogp_r(pri, &_syslog_ss_fun, data, msgid, sdfmt, msgfmt, ap); }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Sat Jan 14 22:19:29 UTC 2017 Modified Files: src/lib/libc/gen: getpwent.c Log Message: don't include machine/param.h already does WTF? To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/lib/libc/gen/getpwent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/getpwent.c diff -u src/lib/libc/gen/getpwent.c:1.81 src/lib/libc/gen/getpwent.c:1.82 --- src/lib/libc/gen/getpwent.c:1.81 Sat Sep 8 11:15:06 2012 +++ src/lib/libc/gen/getpwent.c Sat Jan 14 17:19:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $ */ +/* $NetBSD: getpwent.c,v 1.82 2017/01/14 22:19:29 christos Exp $ */ /*- * Copyright (c) 1997-2000, 2004-2005 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ #if 0 static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $"); +__RCSID("$NetBSD: getpwent.c,v 1.82 2017/01/14 22:19:29 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -117,7 +117,6 @@ __RCSID("$NetBSD: getpwent.c,v 1.81 2012 #endif #ifdef YP -#include #include #include #include
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Thu Jan 12 01:58:39 UTC 2017 Modified Files: src/lib/libc/gen: syslog.c syslog_private.h syslog_ss.c xsyslog.c Log Message: A little more restructuring so that we don't need mutex stuff in syslog_ss. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/lib/libc/gen/syslog.c cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/syslog_private.h \ src/lib/libc/gen/syslog_ss.c src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/syslog.c diff -u src/lib/libc/gen/syslog.c:1.56 src/lib/libc/gen/syslog.c:1.57 --- src/lib/libc/gen/syslog.c:1.56 Wed Jan 11 19:38:01 2017 +++ src/lib/libc/gen/syslog.c Wed Jan 11 20:58:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog.c,v 1.56 2017/01/12 00:38:01 christos Exp $ */ +/* $NetBSD: syslog.c,v 1.57 2017/01/12 01:58:39 christos Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: syslog.c,v 1.56 2017/01/12 00:38:01 christos Exp $"); +__RCSID("$NetBSD: syslog.c,v 1.57 2017/01/12 01:58:39 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -67,6 +67,15 @@ __weak_alias(syslog,_syslog) __weak_alias(vsyslog,_vsyslog) __weak_alias(syslogp,_syslogp) __weak_alias(vsyslogp,_vsyslogp) +__weak_alias(closelog,_closelog) +__weak_alias(openlog,_openlog) +__weak_alias(setlogmask,_setlogmask) +#endif + +static struct syslog_data _syslog_data = SYSLOG_DATA_INIT; + +#ifdef _REENTRANT +static mutex_t syslog_mutex = MUTEX_INITIALIZER; #endif static size_t @@ -103,6 +112,24 @@ timefun(char *p, size_t tbuf_left) return (size_t)(p - op); } +static int +lock(const struct syslog_data *data) +{ + int rv = data == &_syslog_data; + if (rv) + mutex_lock(_mutex); + return rv; +} + +static int +unlock(const struct syslog_data *data) +{ + int rv = data == &_syslog_data; + if (rv) + mutex_unlock(_mutex); + return rv; +} + static struct syslog_fun _syslog_fun = { timefun, strerror_r, @@ -111,8 +138,46 @@ static struct syslog_fun _syslog_fun = { #else vsnprintf, #endif + lock, + unlock, }; +void +openlog(const char *ident, int logstat, int logfac) +{ + openlog_r(ident, logstat, logfac, &_syslog_data); +} + +void +closelog(void) +{ + closelog_r(&_syslog_data); +} + +/* setlogmask -- set the log mask level */ +int +setlogmask(int pmask) +{ + return setlogmask_r(pmask, &_syslog_data); +} + +void +openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data) +{ + lock(data); + _openlog_unlocked_r(ident, logstat, logfac, data); + unlock(data); +} + +void +closelog_r(struct syslog_data *data) +{ + lock(data); + _closelog_unlocked_r(data); + data->log_tag = NULL; + unlock(data); +} + /* * syslog, vsyslog -- * print message on log file; output is intended for syslogd(8). Index: src/lib/libc/gen/syslog_private.h diff -u src/lib/libc/gen/syslog_private.h:1.1 src/lib/libc/gen/syslog_private.h:1.2 --- src/lib/libc/gen/syslog_private.h:1.1 Wed Jan 11 19:38:01 2017 +++ src/lib/libc/gen/syslog_private.h Wed Jan 11 20:58:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog_private.h,v 1.1 2017/01/12 00:38:01 christos Exp $ */ +/* $NetBSD: syslog_private.h,v 1.2 2017/01/12 01:58:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -41,10 +41,13 @@ struct syslog_fun { size_t (*timefun)(char *, size_t); int (*errfun)(int, char *, size_t); int __printflike(3, 0) (*prfun)(char *, size_t, const char *, va_list); + int (*lock)(const struct syslog_data *); + int (*unlock)(const struct syslog_data *); }; void _vxsyslogp_r(int , struct syslog_fun *, struct syslog_data *, const char *, const char *, const char *, va_list); +void _openlog_unlocked_r(const char *, int, int, struct syslog_data *); +void _closelog_unlocked_r(struct syslog_data *); -extern struct syslog_data _syslog_data; extern struct syslog_fun _syslog_ss_fun; Index: src/lib/libc/gen/syslog_ss.c diff -u src/lib/libc/gen/syslog_ss.c:1.1 src/lib/libc/gen/syslog_ss.c:1.2 --- src/lib/libc/gen/syslog_ss.c:1.1 Wed Jan 11 19:38:01 2017 +++ src/lib/libc/gen/syslog_ss.c Wed Jan 11 20:58:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog_ss.c,v 1.1 2017/01/12 00:38:01 christos Exp $ */ +/* $NetBSD: syslog_ss.c,v 1.2 2017/01/12 01:58:39 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: syslog_ss.c,v 1.1 2017/01/12 00:38:01 christos Exp $"); +__RCSID("$NetBSD: syslog_ss.c,v 1.2 2017/01/12 01:58:39 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -54,10 +54,24 @@ timefun_ss(char *p, size_t tbuf_left) #endif } +static int +lock_ss(const struct syslog_data *data __unused) +{ + return 0; +} + +static int +unlock_ss(const struct
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Thu Jan 12 00:38:01 UTC 2017 Modified Files: src/lib/libc/gen: Makefile.inc syslog.c Added Files: src/lib/libc/gen: syslog_private.h syslog_ss.c xsyslog.c Log Message: Split syslog.c to: - syslog_ss.c *_ss api functions (don't use stdio, time) - syslog.c: *syslog* non _ss api functions (use stdio, time) - xsyslog.c> common guts. The motivation for this is not to drag in stdio/locale/floating point/time for every binary, since syslog_ss() is used in __stack_check_fail() for SSP. To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/lib/libc/gen/Makefile.inc cvs rdiff -u -r1.55 -r1.56 src/lib/libc/gen/syslog.c cvs rdiff -u -r0 -r1.1 src/lib/libc/gen/syslog_private.h \ src/lib/libc/gen/syslog_ss.c src/lib/libc/gen/xsyslog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.196 src/lib/libc/gen/Makefile.inc:1.197 --- src/lib/libc/gen/Makefile.inc:1.196 Tue Oct 4 05:41:41 2016 +++ src/lib/libc/gen/Makefile.inc Wed Jan 11 19:38:01 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.196 2016/10/04 09:41:41 kamil Exp $ +# $NetBSD: Makefile.inc,v 1.197 2017/01/12 00:38:01 christos Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -32,12 +32,12 @@ SRCS+= alarm.c alphasort.c arc4random.c siglist.c signal.c signame.c sigrelse.c \ sigset.c sigsetops.c sleep.c \ stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \ - sysctlnametomib.c syslog.c telldir.c time.c timespec_get.c \ + sysctlnametomib.c syslog.c syslog_ss.c telldir.c time.c timespec_get.c \ times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \ ulimit.c uname.c unvis.c usleep.c utime.c utimens.c utmp.c \ utmpx.c valloc.c vis.c wait.c wait3.c waitid.c waitpid.c warn.c \ - warnx.c warnc.c vwarn.c vwarnx.c vwarnc.c verr.c verrx.c verrc.c \ - wordexp.c + warnx.c warnc.c wordexp.c xsyslog.c \ + vwarn.c vwarnx.c vwarnc.c verr.c verrx.c verrc.c # uses alloca COPTS.execvp.c = -Wno-stack-protector Index: src/lib/libc/gen/syslog.c diff -u src/lib/libc/gen/syslog.c:1.55 src/lib/libc/gen/syslog.c:1.56 --- src/lib/libc/gen/syslog.c:1.55 Mon Oct 26 07:44:30 2015 +++ src/lib/libc/gen/syslog.c Wed Jan 11 19:38:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syslog.c,v 1.55 2015/10/26 11:44:30 roy Exp $ */ +/* $NetBSD: syslog.c,v 1.56 2017/01/12 00:38:01 christos Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: syslog.c,v 1.55 2015/10/26 11:44:30 roy Exp $"); +__RCSID("$NetBSD: syslog.c,v 1.56 2017/01/12 00:38:01 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -48,6 +48,7 @@ __RCSID("$NetBSD: syslog.c,v 1.55 2015/1 #include #include +#include #include #include #include @@ -56,32 +57,61 @@ __RCSID("$NetBSD: syslog.c,v 1.55 2015/1 #include #include #include + +#include "syslog_private.h" #include "reentrant.h" #include "extern.h" #ifdef __weak_alias -__weak_alias(closelog,_closelog) -__weak_alias(openlog,_openlog) -__weak_alias(setlogmask,_setlogmask) __weak_alias(syslog,_syslog) __weak_alias(vsyslog,_vsyslog) __weak_alias(syslogp,_syslogp) __weak_alias(vsyslogp,_vsyslogp) #endif -static struct syslog_data sdata = SYSLOG_DATA_INIT; - -static void openlog_unlocked_r(const char *, int, int, -struct syslog_data *); -static void disconnectlog_r(struct syslog_data *); -static void connectlog_r(struct syslog_data *); - -#define LOG_SIGNAL_SAFE (int)0x8000 - +static size_t +timefun(char *p, size_t tbuf_left) +{ + struct timeval tv; + time_t now; + struct tm tmnow; + size_t prlen; + char *op = p; -#ifdef _REENTRANT -static mutex_t syslog_mutex = MUTEX_INITIALIZER; + if (gettimeofday(, NULL) == -1) + return snprintf_ss(p, tbuf_left, "-"); + + /* strftime() implies tzset(), localtime_r() doesn't. */ + tzset(); + now = (time_t) tv.tv_sec; + localtime_r(, ); + + prlen = strftime(p, tbuf_left, "%FT%T", ); + DEC(); + prlen = snprintf(p, tbuf_left, ".%06ld", (long)tv.tv_usec); + DEC(); + prlen = strftime(p, tbuf_left-1, "%z", ); + /* strftime gives eg. "+0200", but we need "+02:00" */ + if (prlen == 5) { + p[prlen+1] = p[prlen]; + p[prlen] = p[prlen-1]; + p[prlen-1] = p[prlen-2]; + p[prlen-2] = ':'; + prlen += 1; + } + DEC(); + return (size_t)(p - op); +} + +static struct syslog_fun _syslog_fun = { + timefun, + strerror_r, +#ifndef __lint__ + _vsnprintf, +#else + vsnprintf, #endif +}; /* * syslog, vsyslog -- @@ -93,14 +123,14 @@ syslog(int pri, const char *fmt, ...) va_list ap; va_start(ap, fmt); - vsyslog(pri, fmt, ap); + _vxsyslogp_r(pri, &_syslog_fun, &_syslog_data, NULL, NULL, fmt, ap); va_end(ap); } void vsyslog(int pri, const char *fmt, va_list ap) { - vsyslog_r(pri, , fmt,
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Tue Jan 10 17:46:47 UTC 2017 Modified Files: src/lib/libc/gen: sysctl.c Log Message: simplify cast. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/lib/libc/gen/sysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/sysctl.c diff -u src/lib/libc/gen/sysctl.c:1.35 src/lib/libc/gen/sysctl.c:1.36 --- src/lib/libc/gen/sysctl.c:1.35 Thu Feb 5 11:05:20 2015 +++ src/lib/libc/gen/sysctl.c Tue Jan 10 12:46:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.c,v 1.35 2015/02/05 16:05:20 christos Exp $ */ +/* $NetBSD: sysctl.c,v 1.36 2017/01/10 17:46:47 christos Exp $ */ /*- * Copyright (c) 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94"; #else -__RCSID("$NetBSD: sysctl.c,v 1.35 2015/02/05 16:05:20 christos Exp $"); +__RCSID("$NetBSD: sysctl.c,v 1.36 2017/01/10 17:46:47 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -313,7 +313,7 @@ user_sysctl(const int *name, unsigned in if (d2 != NULL) memcpy(d2, d1, d); sz += d; - d2 = (struct sysctldesc *)(void *)((char *)d2 + d); + d2 = (void *)((char *)(void *)d2 + d); if (node != NULL) break; }
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Tue Jan 10 17:45:58 UTC 2017 Modified Files: src/lib/libc/gen: asysctl.c Log Message: cast for size_t To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/asysctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/asysctl.c diff -u src/lib/libc/gen/asysctl.c:1.1 src/lib/libc/gen/asysctl.c:1.2 --- src/lib/libc/gen/asysctl.c:1.1 Fri Jun 13 11:45:05 2014 +++ src/lib/libc/gen/asysctl.c Tue Jan 10 12:45:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $ */ +/* $NetBSD: asysctl.c,v 1.2 2017/01/10 17:45:58 christos Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $"); +__RCSID("$NetBSD: asysctl.c,v 1.2 2017/01/10 17:45:58 christos Exp $"); #include "namespace.h" #include @@ -50,7 +50,7 @@ asysctl(const int *oids, size_t oidlen, data = NULL; for (;;) { - if (sysctl(oids, oidlen, data, len, NULL, 0) == 0) { + if (sysctl(oids, (u_int)oidlen, data, len, NULL, 0) == 0) { if (*len == 0) { free(data); return NULL;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: abhinav Date: Mon Dec 26 10:16:43 UTC 2016 Modified Files: src/lib/libc/gen: getpwent.3 Log Message: Add missing full stop. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/lib/libc/gen/getpwent.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/getpwent.3 diff -u src/lib/libc/gen/getpwent.3:1.38 src/lib/libc/gen/getpwent.3:1.39 --- src/lib/libc/gen/getpwent.3:1.38 Thu Apr 28 16:35:05 2011 +++ src/lib/libc/gen/getpwent.3 Mon Dec 26 10:16:43 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: getpwent.3,v 1.38 2011/04/28 16:35:05 wiz Exp $ +.\" $NetBSD: getpwent.3,v 1.39 2016/12/26 10:16:43 abhinav Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -289,7 +289,7 @@ The resulting does not fit in the space defined by .Dv buffer and -.Dv buflen +.Dv buflen . .El .Pp Other
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Sat Dec 17 10:25:49 UTC 2016 Modified Files: src/lib/libc/gen: scandir.3 Log Message: Fix typo. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/gen/scandir.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/scandir.3 diff -u src/lib/libc/gen/scandir.3:1.15 src/lib/libc/gen/scandir.3:1.16 --- src/lib/libc/gen/scandir.3:1.15 Fri Dec 16 04:45:04 2016 +++ src/lib/libc/gen/scandir.3 Sat Dec 17 10:25:49 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: scandir.3,v 1.15 2016/12/16 04:45:04 mrg Exp $ +.\" $NetBSD: scandir.3,v 1.16 2016/12/17 10:25:49 wiz Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -118,5 +118,5 @@ to use .Dq struct dirent ** instead of .Dq void * -for the comparision function, including +for the comparison function, including .Fn alphasort .
CVS commit: src/lib/libc/gen
Module Name:src Committed By: rin Date: Sat Dec 10 14:13:29 UTC 2016 Modified Files: src/lib/libc/gen: exec.3 Log Message: Fix typo; ".Lx" should be ".Nx" To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/gen/exec.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/exec.3 diff -u src/lib/libc/gen/exec.3:1.26 src/lib/libc/gen/exec.3:1.27 --- src/lib/libc/gen/exec.3:1.26 Sat Sep 27 16:42:07 2014 +++ src/lib/libc/gen/exec.3 Sat Dec 10 14:13:29 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: exec.3,v 1.26 2014/09/27 16:42:07 wiz Exp $ +.\" $NetBSD: exec.3,v 1.27 2016/12/10 14:13:29 rin Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -284,5 +284,5 @@ The function appeared first in QNX and the .Fn execvpe function exists on both -.Lx +.Nx and QNX.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: christos Date: Tue Oct 4 12:48:15 UTC 2016 Modified Files: src/lib/libc/gen: timespec_get.c Log Message: return 0 on unsupported bases. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/timespec_get.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/timespec_get.c diff -u src/lib/libc/gen/timespec_get.c:1.1 src/lib/libc/gen/timespec_get.c:1.2 --- src/lib/libc/gen/timespec_get.c:1.1 Tue Oct 4 05:41:41 2016 +++ src/lib/libc/gen/timespec_get.c Tue Oct 4 08:48:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: timespec_get.c,v 1.1 2016/10/04 09:41:41 kamil Exp $ */ +/* $NetBSD: timespec_get.c,v 1.2 2016/10/04 12:48:15 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: timespec_get.c,v 1.1 2016/10/04 09:41:41 kamil Exp $"); +__RCSID("$NetBSD: timespec_get.c,v 1.2 2016/10/04 12:48:15 christos Exp $"); #endif /* !defined lint */ #include @@ -47,8 +47,11 @@ timespec_get(struct timespec *ts, int ba switch (base) { case TIME_UTC: - if (clock_gettime(CLOCK_REALTIME, ts) != 0) + if (clock_gettime(CLOCK_REALTIME, ts) == -1) return 0; + break; + default: + return 0; } return base;
CVS commit: src/lib/libc/gen
Module Name:src Committed By: wiz Date: Tue Oct 4 10:46:40 UTC 2016 Modified Files: src/lib/libc/gen: timespec_get.3 Log Message: Fix xref. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/lib/libc/gen/timespec_get.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/timespec_get.3 diff -u src/lib/libc/gen/timespec_get.3:1.1 src/lib/libc/gen/timespec_get.3:1.2 --- src/lib/libc/gen/timespec_get.3:1.1 Tue Oct 4 09:41:41 2016 +++ src/lib/libc/gen/timespec_get.3 Tue Oct 4 10:46:40 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: timespec_get.3,v 1.1 2016/10/04 09:41:41 kamil Exp $ +.\" $NetBSD: timespec_get.3,v 1.2 2016/10/04 10:46:40 wiz Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -61,7 +61,7 @@ if successful, otherwise on failure. .\" .Sh ERRORS .Sh SEE ALSO -.Xr clock_gettime 3 +.Xr clock_gettime 2 .Sh STANDARDS The .Nm
CVS commit: src/lib/libc/gen
Module Name:src Committed By: dholland Date: Fri Sep 30 06:22:21 UTC 2016 Modified Files: src/lib/libc/gen: sysctlgetmibinfo.c Log Message: Be more careful about preserving errno. Might conceivably be related to PR 51432. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/sysctlgetmibinfo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/sysctlgetmibinfo.c diff -u src/lib/libc/gen/sysctlgetmibinfo.c:1.12 src/lib/libc/gen/sysctlgetmibinfo.c:1.13 --- src/lib/libc/gen/sysctlgetmibinfo.c:1.12 Fri Sep 30 06:16:47 2016 +++ src/lib/libc/gen/sysctlgetmibinfo.c Fri Sep 30 06:22:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $ */ +/* $NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $ */ /*- * Copyright (c) 2003,2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.12 2016/09/30 06:16:47 dholland Exp $"); +__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $"); #endif /* LIBC_SCCS and not lint */ #ifndef RUMP_ACTION @@ -277,6 +277,7 @@ __learn_tree(int *name, u_int namelen, s struct sysctlnode qnode; uint32_t rc; size_t sz; + int serrno; if (pnode == NULL) pnode = _mibroot; @@ -303,7 +304,9 @@ __learn_tree(int *name, u_int namelen, s rc = sysctl(name, namelen + 1, pnode->sysctl_child, , , sizeof(qnode)); if (sz == 0) { + serrno = errno; free(pnode->sysctl_child); + errno = serrno; pnode->sysctl_child = NULL; return (rc); } @@ -324,7 +327,9 @@ __learn_tree(int *name, u_int namelen, s rc = sysctl(name, namelen + 1, pnode->sysctl_child, , , sizeof(qnode)); if (rc) { + serrno = errno; free(pnode->sysctl_child); + errno = serrno; pnode->sysctl_child = NULL; return (rc); }