CVS commit: [netbsd-6-1] src/lib/libc/regex

2015-02-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb 21 12:56:30 UTC 2015

Modified Files:
src/lib/libc/regex [netbsd-6-1]: regcomp.c

Log Message:
Apply patch, requested by joerg in ticket #1257:

lib/libc/regex/regcomp.c (patch)

Fix a multiplication overflow in allocation, which has been fixed
differently in rev. 1.34 in -current.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.32.8.1 src/lib/libc/regex/regcomp.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/regex/regcomp.c
diff -u src/lib/libc/regex/regcomp.c:1.32 src/lib/libc/regex/regcomp.c:1.32.8.1
--- src/lib/libc/regex/regcomp.c:1.32	Tue Nov  8 19:25:45 2011
+++ src/lib/libc/regex/regcomp.c	Sat Feb 21 12:56:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: regcomp.c,v 1.32 2011/11/08 19:25:45 christos Exp $	*/
+/*	$NetBSD: regcomp.c,v 1.32.8.1 2015/02/21 12:56:30 martin Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = @(#)regcomp.c	8.5 (Berkeley) 3/20/94;
 #else
-__RCSID($NetBSD: regcomp.c,v 1.32 2011/11/08 19:25:45 christos Exp $);
+__RCSID($NetBSD: regcomp.c,v 1.32.8.1 2015/02/21 12:56:30 martin Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -261,12 +261,15 @@ regcomp(
 	} else
 		len = strlen(pattern);
 
+	p-ssize = len/(size_t)2*(size_t)3 + (size_t)1;	/* ugh */
+	if (p-ssize  SIZE_MAX / sizeof(sop))
+		return(REG_ESPACE);
+
 	/* do the mallocs early so failure handling is easy */
 	g = (struct re_guts *)malloc(sizeof(struct re_guts) +
 			(NC-1)*sizeof(cat_t));
 	if (g == NULL)
 		return(REG_ESPACE);
-	p-ssize = len/(size_t)2*(size_t)3 + (size_t)1;	/* ugh */
 	p-strip = malloc(p-ssize * sizeof(sop));
 	p-slen = 0;
 	if (p-strip == NULL) {
@@ -1243,7 +1246,7 @@ allocset(
 		nc = p-ncsalloc;
 		assert(nc % CHAR_BIT == 0);
 		nbytes = nc / CHAR_BIT * css;
-		if (MEMSIZE(p)  MEMLIMIT)
+		if (MEMSIZE(p)  MEMLIMIT || nc  SIZE_MAX / sizeof(cset))
 			goto oomem;
 		if (p-g-sets == NULL)
 			p-g-sets = malloc(nc * sizeof(cset));
@@ -1773,7 +1776,7 @@ enlarge(
 
 	osize = p-ssize;
 	p-ssize = size;
-	if (MEMSIZE(p)  MEMLIMIT)
+	if (MEMSIZE(p)  MEMLIMIT || p-ssize  SIZE_MAX / sizeof(sop))
 		goto oomem;
 	sp = realloc(p-strip, p-ssize * sizeof(sop));
 	if (sp == NULL) {
@@ -1800,6 +1803,11 @@ stripsnug(
 	_DIAGASSERT(g != NULL);
 
 	g-nstates = p-slen;
+	if (p-slen  SIZE_MAX / sizeof(sop)) {
+		SETERROR(REG_ESPACE);
+		g-strip = p-strip;
+		return;
+	}
 	g-strip = realloc(p-strip, p-slen * sizeof(sop));
 	if (g-strip == NULL) {
 		SETERROR(REG_ESPACE);



CVS commit: [netbsd-6-1] src/lib

2014-12-25 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 26 05:32:50 UTC 2014

Modified Files:
src/lib [netbsd-6-1]: Makefile

Log Message:
Pullup additional patch for ticket #1217:

lib/Makefile1.204 via patch

libbind now depends on heimdal, so push it after the third barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.181.2.2 -r1.181.2.2.2.1 src/lib/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/Makefile
diff -u src/lib/Makefile:1.181.2.2 src/lib/Makefile:1.181.2.2.2.1
--- src/lib/Makefile:1.181.2.2	Sun Nov 18 22:38:32 2012
+++ src/lib/Makefile	Fri Dec 26 05:32:50 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.181.2.2 2012/11/18 22:38:32 riz Exp $
+#	$NetBSD: Makefile,v 1.181.2.2.2.1 2014/12/26 05:32:50 msaitoh Exp $
 #	from: @(#)Makefile	5.25.1.1 (Berkeley) 5/7/91
 
 .include bsd.own.mk
@@ -159,7 +159,6 @@ SUBDIR+=	../crypto/external/bsd/openssh/
 SUBDIR+=	../crypto/external/bsd/netpgp/lib  # depends on libcrypto, ...
 .endif
 
-SUBDIR+=	../external/bsd/bind/lib	# depends on libcrypto
 SUBDIR+=	../external/bsd/fetch/lib	# depends on libssl
 
 .if (${MKLDAP} != no)
@@ -169,6 +168,8 @@ SUBDIR+=	../external/bsd/openldap/lib	# 
 # 3rd library dependency barrier 
 SUBDIR+=	.WAIT
 
+SUBDIR+=	../external/bsd/bind/lib	# depends on heimdal, libcrypto
+
 SUBDIR+=	librumpdev	# depends on librump
 SUBDIR+=	librumpnet	# depends on librump
 SUBDIR+=	librumpvfs	# depends on librump



CVS commit: [netbsd-6-1] src/lib/libc/arch/sparc/gen

2014-08-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug  7 08:53:40 UTC 2014

Modified Files:
src/lib/libc/arch/sparc/gen [netbsd-6-1]: _setjmp.S

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1100):
lib/libc/arch/sparc/gen/_setjmp.S: revision 1.10
Use save instruction to set up a local stack frame.
This fixes a segmentation fault caused by bash 4.3 on sparc64
kernels with 32-bit userland, bash uses _setjmp/_longjmp heavyly
via sigsetjmp/siglongjmp since 4.3.
For 32-bit compat library which is compiled with -mcpu=ultrasparc
option (and define __sparc_v9__), use a similar code to 64-bit
library.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.18.1 src/lib/libc/arch/sparc/gen/_setjmp.S

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/arch/sparc/gen/_setjmp.S
diff -u src/lib/libc/arch/sparc/gen/_setjmp.S:1.9 src/lib/libc/arch/sparc/gen/_setjmp.S:1.9.18.1
--- src/lib/libc/arch/sparc/gen/_setjmp.S:1.9	Sat Apr 30 23:41:12 2011
+++ src/lib/libc/arch/sparc/gen/_setjmp.S	Thu Aug  7 08:53:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: _setjmp.S,v 1.9 2011/04/30 23:41:12 martin Exp $	*/
+/*	$NetBSD: _setjmp.S,v 1.9.18.1 2014/08/07 08:53:40 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include machine/trap.h
 
 #if defined(LIBC_SCCS)  !defined(lint)
-RCSID($NetBSD: _setjmp.S,v 1.9 2011/04/30 23:41:12 martin Exp $)
+RCSID($NetBSD: _setjmp.S,v 1.9.18.1 2014/08/07 08:53:40 msaitoh Exp $)
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -59,26 +59,46 @@ ENTRY(_setjmp)
 	 clr	%o0		! return 0
 
 ENTRY(_longjmp)
-	sub	%sp, 64, %sp	! set up a local stack frame
-	tst	%o1		! compute v ? v : 1
+#ifdef __sparc_v9__
+	save	%sp, -CCFSZ, %sp
+	flushw
+	/*
+	 * We restore the saved stack pointer to %fp, then issue
+	 * a `restore' instruction which will reload the register
+	 * window from the stack.
+	 */
+	ld	[%i0 + 16], %g3
+	ld	[%i0 + 24], %g2
+	ld	[%i0 + 48], %g4
+	ld	[%i0 + 52], %g7
+	ld	[%i0 + 4], %i7	/* restore return pc */
+	ld	[%i0 + 0], %fp	/* and stack pointer */
+	mov	1, %i0
+	movrnz	%i1, %i1, %i0	! compute v ? v : 1
+	ret
+	 restore
+#else
+	save	%sp, -64, %sp	! set up a local stack frame
+	tst	%i1		! compute v ? v : 1
 	be,a	0f
-	 mov	1, %o1
+	 mov	1, %i1
 0:
 	t	ST_FLUSHWIN	! flush register windows out to the stack
 
 	/* restore globals */
-	ld	[%o0 + 16], %g3
-	ld	[%o0 + 24], %g2
-	ld	[%o0 + 48], %g4
-	ld	[%o0 + 52], %g7
+	ld	[%i0 + 16], %g3
+	ld	[%i0 + 24], %g2
+	ld	[%i0 + 48], %g4
+	ld	[%i0 + 52], %g7
 
 	/*
 	 * We restore the saved stack pointer to %fp, then issue
 	 * a `restore' instruction which will reload the register
 	 * window from the stack.
 	 */
-	ld	[%o0+4], %o7	/* restore return pc */
-	ld	[%o0+0], %fp	/* and stack pointer */
+	ld	[%i0+4], %i7	/* restore return pc */
+	ld	[%i0+0], %fp	/* and stack pointer */
 
-	retl			! success, return %o1
-	 restore	%o1, 0, %o0
+	ret			! success, return %i1
+	 restore	%i1, 0, %o0
+#endif



CVS commit: [netbsd-6-1] src/lib/libcurses

2013-09-26 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Sep 26 14:21:00 UTC 2013

Modified Files:
src/lib/libcurses [netbsd-6-1]: setterm.c

Log Message:
Pull up following revision(s) (requested by dsainty in ticket #960):
lib/libcurses/setterm.c: revision 1.51
Fix a NULL dereference if the exit_alt_charset_mode capability is not
defined.
The previous version of this file changed a terminal initialisation test on
the exit_attribute_mode capability, checking for the exit_alt_charset_mode
capability as a substring, rather than performing a search for the
hard-coded
^O character.
That works better on terminals where ^O is not the correct value for
exit_alt_charset_mode.  But it works worse on terminals that don't have a
definition specified for exit_alt_charset_mode.
For example:
% TERMCAP='xterm:me=\E[m:' TERM=xterm vi
segmentation fault (core dumped)  TERMCAP='xterm:me=\E[m:' TERM=xterm vi
The crash can be avoided (without fixing the bug) by defining
exit_alt_charset_mode:
% TERMCAP='xterm|:me=\E[m:ae=:' TERM=xterm vi
ex/vi: Error: xterm: No such process
We now test exit_alt_charset_mode for NULL before continuing with the fatal
test, restoring the original no-crash behaviour.
XXX does_ctrl_o() is now just a naive reimplementation of strstr(), so
should
probably just use strstr() instead.


To generate a diff of this commit:
cvs rdiff -u -r1.48.4.1 -r1.48.4.1.2.1 src/lib/libcurses/setterm.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/libcurses/setterm.c
diff -u src/lib/libcurses/setterm.c:1.48.4.1 src/lib/libcurses/setterm.c:1.48.4.1.2.1
--- src/lib/libcurses/setterm.c:1.48.4.1	Sat May 11 21:48:23 2013
+++ src/lib/libcurses/setterm.c	Thu Sep 26 14:21:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: setterm.c,v 1.48.4.1 2013/05/11 21:48:23 riz Exp $	*/
+/*	$NetBSD: setterm.c,v 1.48.4.1.2.1 2013/09/26 14:21:00 riz Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)setterm.c	8.8 (Berkeley) 10/25/94;
 #else
-__RCSID($NetBSD: setterm.c,v 1.48.4.1 2013/05/11 21:48:23 riz Exp $);
+__RCSID($NetBSD: setterm.c,v 1.48.4.1.2.1 2013/09/26 14:21:00 riz Exp $);
 #endif
 #endif /* not lint */
 
@@ -172,6 +172,7 @@ _cursesi_setterm(char *type, SCREEN *scr
 	 * It might turn off ACS, so check for that.
 	 */
 	if (t_exit_attribute_mode(screen-term) != NULL 
+	t_exit_alt_charset_mode(screen-term) != NULL 
 	does_ctrl_o(t_exit_attribute_mode(screen-term),
 	t_exit_alt_charset_mode(screen-term)))
 		screen-mask_me = 0;



CVS commit: [netbsd-6-1] src/lib/libpthread

2013-09-25 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Sep 26 02:01:14 UTC 2013

Modified Files:
src/lib/libpthread [netbsd-6-1]: pthread.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #959):
lib/libpthread/pthread.c: revision 1.137
return errno if pthread_create hits the system limit, not just -1
(this is not entirely correct because it can return ENOMEM which is
not mentioned in the spec, but there are other places in pthread_create
whete ENOMEM is returned -- it at all, this should be fixed everywhere)


To generate a diff of this commit:
cvs rdiff -u -r1.125.4.3 -r1.125.4.3.2.1 src/lib/libpthread/pthread.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/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.125.4.3 src/lib/libpthread/pthread.c:1.125.4.3.2.1
--- src/lib/libpthread/pthread.c:1.125.4.3	Mon Apr 29 01:50:19 2013
+++ src/lib/libpthread/pthread.c	Thu Sep 26 02:01:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.c,v 1.125.4.3 2013/04/29 01:50:19 riz Exp $	*/
+/*	$NetBSD: pthread.c,v 1.125.4.3.2.1 2013/09/26 02:01:14 riz Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: pthread.c,v 1.125.4.3 2013/04/29 01:50:19 riz Exp $);
+__RCSID($NetBSD: pthread.c,v 1.125.4.3.2.1 2013/09/26 02:01:14 riz Exp $);
 
 #define	__EXPOSE_STACK	1
 
@@ -443,6 +443,7 @@ pthread_create(pthread_t *thread, const 
 		flag |= LWP_SUSPENDED;
 	ret = _lwp_create(newthread-pt_uc, flag, newthread-pt_lid);
 	if (ret != 0) {
+		ret = errno;
 		pthread_mutex_lock(newthread-pt_lock);
 		/* Will unlock and free name. */
 		pthread__reap(newthread);



CVS commit: [netbsd-6-1] src/lib/libc/stdlib

2013-09-14 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep 14 13:45:13 UTC 2013

Modified Files:
src/lib/libc/stdlib [netbsd-6-1]: _env.c

Log Message:
Pull up following revision(s) (requested by tron in ticket #940):
lib/libc/stdlib/_env.c: revision 1.8
Don't scrub the environment unless we are going to change it. This should
prevent crashes in applications which carefully and manually construct
a temporary environment and later restore the original environment
like Emacs 24.
Problem reported by Thomas Klausner on pkgsrc-users mailing list.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.16.1 src/lib/libc/stdlib/_env.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/stdlib/_env.c
diff -u src/lib/libc/stdlib/_env.c:1.6 src/lib/libc/stdlib/_env.c:1.6.16.1
--- src/lib/libc/stdlib/_env.c:1.6	Thu Oct  6 20:31:41 2011
+++ src/lib/libc/stdlib/_env.c	Sat Sep 14 13:45:13 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $ */
+/*	$NetBSD: _env.c,v 1.6.16.1 2013/09/14 13:45:13 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: _env.c,v 1.6 2011/10/06 20:31:41 christos Exp $);
+__RCSID($NetBSD: _env.c,v 1.6.16.1 2013/09/14 13:45:13 bouyer Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -256,10 +256,6 @@ __getenvslot(const char *name, size_t l_
 	size_t new_size, num_entries, required_size;
 	char **new_environ;
 
-	/* Does the environ need scrubbing? */
-	if (environ != allocated_environ  allocated_environ != NULL)
-		__scrubenv();
-
 	/* Search for an existing environment variable of the given name. */
 	num_entries = 0;
 	while (environ[num_entries] != NULL) {
@@ -275,6 +271,10 @@ __getenvslot(const char *name, size_t l_
 	if (!allocate)
 		return -1;
 
+	/* Does the environ need scrubbing? */
+	if (environ != allocated_environ  allocated_environ != NULL)
+		__scrubenv();
+
 	/* Create a new slot in the environment. */
 	required_size = num_entries + 1;
 	if (environ == allocated_environ 



CVS commit: [netbsd-6-1] src/lib/libm/arch

2013-06-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jun 14 02:43:36 UTC 2013

Modified Files:
src/lib/libm/arch/i387 [netbsd-6-1]: fenv.c
src/lib/libm/arch/x86_64 [netbsd-6-1]: fenv.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #899):
lib/libm/arch/i387/fenv.c: revision 1.5
lib/libm/arch/x86_64/fenv.c: revision 1.3-1.4
Fix amd64 feraiseexcept so that it actually traps.
The call to fwait got lost somewhere along the line; the i387 code has it.
Fix sense of fegetexcept on x86.
Somehow I overlooked this when I fixed feenableexcept and fedisableexcept
last summer.


To generate a diff of this commit:
cvs rdiff -u -r1.3.8.1 -r1.3.8.1.6.1 src/lib/libm/arch/i387/fenv.c
cvs rdiff -u -r1.1.8.1 -r1.1.8.1.6.1 src/lib/libm/arch/x86_64/fenv.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/libm/arch/i387/fenv.c
diff -u src/lib/libm/arch/i387/fenv.c:1.3.8.1 src/lib/libm/arch/i387/fenv.c:1.3.8.1.6.1
--- src/lib/libm/arch/i387/fenv.c:1.3.8.1	Sun Aug 12 18:53:11 2012
+++ src/lib/libm/arch/i387/fenv.c	Fri Jun 14 02:43:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.3.8.1 2012/08/12 18:53:11 martin Exp $ */
+/* $NetBSD: fenv.c,v 1.3.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz d...@freebsd.org
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: fenv.c,v 1.3.8.1 2012/08/12 18:53:11 martin Exp $);
+__RCSID($NetBSD: fenv.c,v 1.3.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/sysctl.h
@@ -510,5 +510,5 @@ fegetexcept(void)
 	 */
 	__fnstcw(control);
 
-	return (control  FE_ALL_EXCEPT);
+	return (~control  FE_ALL_EXCEPT);
 }

Index: src/lib/libm/arch/x86_64/fenv.c
diff -u src/lib/libm/arch/x86_64/fenv.c:1.1.8.1 src/lib/libm/arch/x86_64/fenv.c:1.1.8.1.6.1
--- src/lib/libm/arch/x86_64/fenv.c:1.1.8.1	Sun Aug 12 18:53:11 2012
+++ src/lib/libm/arch/x86_64/fenv.c	Fri Jun 14 02:43:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.1.8.1 2012/08/12 18:53:11 martin Exp $ */
+/* $NetBSD: fenv.c,v 1.1.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz das (at) FreeBSD.ORG
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: fenv.c,v 1.1.8.1 2012/08/12 18:53:11 martin Exp $);
+__RCSID($NetBSD: fenv.c,v 1.1.8.1.6.1 2013/06/14 02:43:36 msaitoh Exp $);
 
 #include assert.h
 #include fenv.h
@@ -58,6 +58,10 @@ __RCSID($NetBSD: fenv.c,v 1.1.8.1 2012/
 #define	__fnstenv(__env)	__asm__ __volatile__ \
 	(fnstenv %0 : =m (*(__env)))
 
+/* Check for and handle pending unmasked x87 pending FPU exceptions */
+#define	__fwait(__env)		__asm__	__volatile__	\
+	(fwait)
+
 /* Load the MXCSR register */
 #define	__ldmxcsr(__mxcsr)	__asm__ __volatile__ \
 	(ldmxcsr %0 : : m (__mxcsr))
@@ -178,6 +182,7 @@ feraiseexcept(int excepts)
 
 	ex = excepts  FE_ALL_EXCEPT;
 	fesetexceptflag((unsigned int *)excepts, excepts);
+	__fwait();
 
 	/* Success */
 	return (0);
@@ -519,6 +524,6 @@ fegetexcept(void)
 	 */
 	__fnstcw(control);
 
-	return (control  FE_ALL_EXCEPT);
+	return (~control  FE_ALL_EXCEPT);
 }