CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Mon Mar 11 20:05:15 UTC 2024 Modified Files: src/lib/libc/gen [netbsd-8]: getcap.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #1947): lib/libc/gen/getcap.c: revision 1.58 Fix memory leak in getent() Memory was not freed if record was not found To generate a diff of this commit: cvs rdiff -u -r1.56.8.1 -r1.56.8.2 src/lib/libc/gen/getcap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Mon Mar 11 20:05:15 UTC 2024 Modified Files: src/lib/libc/gen [netbsd-8]: getcap.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #1947): lib/libc/gen/getcap.c: revision 1.58 Fix memory leak in getent() Memory was not freed if record was not found To generate a diff of this commit: cvs rdiff -u -r1.56.8.1 -r1.56.8.2 src/lib/libc/gen/getcap.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/getcap.c diff -u src/lib/libc/gen/getcap.c:1.56.8.1 src/lib/libc/gen/getcap.c:1.56.8.2 --- src/lib/libc/gen/getcap.c:1.56.8.1 Tue Jul 4 12:57:45 2017 +++ src/lib/libc/gen/getcap.c Mon Mar 11 20:05:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: getcap.c,v 1.56.8.1 2017/07/04 12:57:45 martin Exp $ */ +/* $NetBSD: getcap.c,v 1.56.8.2 2024/03/11 20:05:15 martin Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; #else -__RCSID("$NetBSD: getcap.c,v 1.56.8.1 2017/07/04 12:57:45 martin Exp $"); +__RCSID("$NetBSD: getcap.c,v 1.56.8.2 2024/03/11 20:05:15 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -502,8 +502,10 @@ getent(char **cap, size_t *len, const ch break; } - if (!foundit) + if (!foundit) { + free(record); return -1; + } /* * Got the capability record, but now we have to expand all tc=name
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Fri Jan 6 13:50:03 UTC 2023 Modified Files: src/lib/libc/gen [netbsd-8]: err.3 Log Message: Pull up following revision(s) (requested by kre in ticket #1782): lib/libc/gen/err.3: revision 1.23 Add errc() and verrc() to the list of functions which do not return, but exit() instead. This was omitted when the *c() set of functions were added in 2014. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.21.18.1 src/lib/libc/gen/err.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Fri Jan 6 13:50:03 UTC 2023 Modified Files: src/lib/libc/gen [netbsd-8]: err.3 Log Message: Pull up following revision(s) (requested by kre in ticket #1782): lib/libc/gen/err.3: revision 1.23 Add errc() and verrc() to the list of functions which do not return, but exit() instead. This was omitted when the *c() set of functions were added in 2014. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.21.18.1 src/lib/libc/gen/err.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/err.3 diff -u src/lib/libc/gen/err.3:1.21 src/lib/libc/gen/err.3:1.21.18.1 --- src/lib/libc/gen/err.3:1.21 Thu Jan 16 17:21:38 2014 +++ src/lib/libc/gen/err.3 Fri Jan 6 13:50:03 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: err.3,v 1.21 2014/01/16 17:21:38 christos Exp $ +.\" $NetBSD: err.3,v 1.21.18.1 2023/01/06 13:50:03 martin Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)err.3 8.1 (Berkeley) 6/9/93 .\" -.Dd January 16, 2014 +.Dd January 5, 2023 .Dt ERR 3 .Os .Sh NAME @@ -124,6 +124,8 @@ functions will not output this error mes The .Fn err , .Fn verr , +.Fn errc , +.Fn verrc , .Fn errx , and .Fn verrx
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Sun Jan 27 18:25:52 UTC 2019 Modified Files: src/lib/libc/gen [netbsd-8]: popen.c Log Message: Pull up following revision(s) (requested by christos in ticket #1170): lib/libc/gen/popen.c: revision 1.36 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.35.8.1 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.35.8.1 --- src/lib/libc/gen/popen.c:1.35 Mon Feb 2 22:07:05 2015 +++ src/lib/libc/gen/popen.c Sun Jan 27 18:25:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.35 2015/02/02 22:07:05 christos Exp $ */ +/* $NetBSD: popen.c,v 1.35.8.1 2019/01/27 18:25:52 martin 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.35.8.1 2019/01/27 18:25:52 martin 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: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Sun Jan 27 18:25:52 UTC 2019 Modified Files: src/lib/libc/gen [netbsd-8]: popen.c Log Message: Pull up following revision(s) (requested by christos in ticket #1170): lib/libc/gen/popen.c: revision 1.36 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.35.8.1 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.
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Tue Jan 16 14:15:50 UTC 2018 Modified Files: src/lib/libc/gen [netbsd-8]: vis.c Log Message: Pull up the following, requested by maya in #411: lib/libc/gen/vis.c 1.74 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.73.4.1 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.
CVS commit: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: martin Date: Tue Jan 16 14:15:50 UTC 2018 Modified Files: src/lib/libc/gen [netbsd-8]: vis.c Log Message: Pull up the following, requested by maya in #411: lib/libc/gen/vis.c 1.74 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.73.4.1 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.73.4.1 --- src/lib/libc/gen/vis.c:1.73 Sun Apr 23 01:58:48 2017 +++ src/lib/libc/gen/vis.c Tue Jan 16 14:15:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vis.c,v 1.73 2017/04/23 01:58:48 christos Exp $ */ +/* $NetBSD: vis.c,v 1.73.4.1 2018/01/16 14:15:50 martin 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.73.4.1 2018/01/16 14:15:50 martin 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: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: snj Date: Sun Dec 10 10:18:22 UTC 2017 Modified Files: src/lib/libc/gen [netbsd-8]: signal.3 Log Message: Pull up following revision(s) (requested by dholland in ticket #433): lib/libc/gen/signal.3: revision 1.28 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.27.8.1 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.27.8.1 --- src/lib/libc/gen/signal.3:1.27 Mon Jun 6 08:28:18 2016 +++ src/lib/libc/gen/signal.3 Sun Dec 10 10:18: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.27.8.1 2017/12/10 10:18:22 snj 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: [netbsd-8] src/lib/libc/gen
Module Name:src Committed By: snj Date: Sun Dec 10 10:18:22 UTC 2017 Modified Files: src/lib/libc/gen [netbsd-8]: signal.3 Log Message: Pull up following revision(s) (requested by dholland in ticket #433): lib/libc/gen/signal.3: revision 1.28 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.27.8.1 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.