Subject: lib/35129: exit in utmpx code should be _exit
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 11/26/2006 17:25:00
>Number:         35129
>Category:       lib
>Synopsis:       exit in utmpx code should be _exit
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 26 17:25:00 +0000 2006
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Release:        NetBSD 4.99.3 (-20061010)
>Organization:
   Harvard EECS
>Environment:
System: NetBSD tanaqui 4.99.3 NetBSD 4.99.3 (TANAQUI) #6: Tue Oct 10 19:32:37 EDT 2006 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

While looking for something else I noticed an error exit() in the
utmpx code that should really be an _exit(). It's inside a private
fork within libc. With exit(), user atexit functions will be called
with possibly undesirable effects, and buffered data in stdio streams
could end up duplicated in the output.

>How-To-Repeat:
	-
>Fix:

patch against -r1.23 of lib/libc/gen/utmpx.c:

Index: utmpx.c
===================================================================
RCS file: /cvsroot/src/lib/libc/gen/utmpx.c,v
retrieving revision 1.23
diff -u -r1.23 utmpx.c
--- utmpx.c	13 Sep 2005 01:44:09 -0000	1.23
+++ utmpx.c	26 Nov 2006 17:18:07 -0000
@@ -286,7 +286,7 @@
 	case 0:
 		(void)execl(_PATH_UTMP_UPDATE,
 		    strrchr(_PATH_UTMP_UPDATE, '/') + 1, buf, NULL);
-		exit(1);
+		_exit(1);
 		/*NOTREACHED*/
 	case -1:
 		return NULL;