[Midnightbsd-cvs] src [10572] trunk/lib/libc/nls/msgcat.c: use cloexec

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Jun 7 21:44:36 EDT 2018


Revision: 10572
          http://svnweb.midnightbsd.org/src/?rev=10572
Author:   laffer1
Date:     2018-06-07 21:44:35 -0400 (Thu, 07 Jun 2018)
Log Message:
-----------
use cloexec

Modified Paths:
--------------
    trunk/lib/libc/nls/msgcat.c

Modified: trunk/lib/libc/nls/msgcat.c
===================================================================
--- trunk/lib/libc/nls/msgcat.c	2018-06-08 01:43:44 UTC (rev 10571)
+++ trunk/lib/libc/nls/msgcat.c	2018-06-08 01:44:35 UTC (rev 10572)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /***********************************************************
 Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
 Copyright 2010, Gabor Kovesdan <gabor at FreeBSD.org>
@@ -32,7 +33,7 @@
 ******************************************************************/
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/nls/msgcat.c 304862 2016-08-26 21:19:23Z ache $");
 
 #define _NLS_PRIVATE
 
@@ -47,7 +48,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <locale.h>
 #include <nl_types.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -56,7 +56,7 @@
 #include <unistd.h>
 #include "un-namespace.h"
 
-#include "../locale/setlocale.h"        /* for ENCODING_LEN */
+#include "../locale/xlocale_private.h"
 
 #define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
 
@@ -82,6 +82,8 @@
 				  if (np != NULL) {				\
 				  	np->name = strdup(n);			\
 					np->path = NULL;			\
+					np->catd = NLERR;			\
+					np->refcount = 0;			\
 					np->lang = (l == NULL) ? NULL :		\
 					    strdup(l);				\
 					np->caterrno = e;			\
@@ -113,9 +115,10 @@
 {
 	struct stat sbuf;
 	struct catentry *np;
-	char *base, *cptr, *cptr1, *lang, *nlspath, *pathP, *pcode;
-	char *plang, *pter, *tmpptr;
+	char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode;
+	char *plang, *pter;
 	int saverr, spcleft;
+	const char *lang, *tmpptr;
 	char path[PATH_MAX];
 
 	/* sanity checking */
@@ -127,7 +130,7 @@
 		lang = NULL;
 	else {
 		if (type == NL_CAT_LOCALE)
-			lang = setlocale(LC_MESSAGES, NULL);
+			lang = querylocale(LC_MESSAGES_MASK, __get_locale());
 		else
 			lang = getenv("LANG");
 
@@ -384,7 +387,7 @@
 	}
 	UNLOCK;
 
-	if ((fd = _open(path, O_RDONLY)) == -1) {
+	if ((fd = _open(path, O_RDONLY | O_CLOEXEC)) == -1) {
 		SAVEFAIL(name, lang, errno);
 		NLRETERR(errno);
 	}



More information about the Midnightbsd-cvs mailing list