From MAILER-DAEMON Wed Dec 09 11:24:52 2020 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kn2Gl-0004Nj-E8 for mharc-findutils-patches@gnu.org; Wed, 09 Dec 2020 11:24:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn2Gg-0004Lk-JK; Wed, 09 Dec 2020 11:24:44 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:46985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn2GW-0004Kz-El; Wed, 09 Dec 2020 11:24:40 -0500 Received: from [192.168.101.10] ([91.12.160.30]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MxV4T-1ju5G02egT-00xqtg; Wed, 09 Dec 2020 17:24:29 +0100 To: "bug-findutils@gnu.org" , findutils-patches From: Bernhard Voelker Subject: [PATCH 0/2]: maint: use *-safer gnulib functions more consistently Message-ID: <51c0b5fd-357c-4e36-b857-8dcb78fd7183@bernhard-voelker.de> Date: Wed, 9 Dec 2020 17:24:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4C6963BBFC02CA394EC64BA1" Content-Language: en-US X-Provags-ID: V03:K1:5fnek/vR48v2gm6YLPip2EPrD6b+As8+RyMv7jhOdqVPyTV0V/9 V6S01pwkOoszkkM7oimiNcKTyQdX5RbevjldnnQZ9Oha1o3johQfTY1oKDpS5Vb6oVAAWj5 8+sFeHZPVBOj7D6k81IgyepGAai2pz8K2/1zrUqGcNiIElmgUFaOcygb5AKEdnpzwbarAWC RS0gG+WHwF+lXPcaIi2xQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:nKFKuLgHc6w=:/wLkd+YjR1LeaFPLTbSVh6 Gfk9qljD48HEZek0R0KzkfKlhZMruytXlZZ8y4qFeqbXb3XdUHCjU9JsuZH+eSjsoOVLOLqbl 9Zjsq19j8UoceR4D6vCqGgbftCLFmWYcqs+18p9rIecHv4te6noHkSUtLgN/68c4jnvjhOo0t c1N9rED2luEK0kojvRm66uJky4MGXX83iMTudcGw9kANg6wQZ4Y1hERLmPqImUrmlVQdNr7Nt ugcmZsf5jiEDJQK3cyv7nwnk9de2+G58HMZYhKqJsIYJewhf5ohXudUXG17pNXq6/ZZhRiuoZ Oq6FA6cPVkwi/r6BanDi6sR6E4N/T8PuYm2/SMrOb6hUXtwPAxTpWnW4EtJbjrLQE8cF2EVo9 SyfwykenzIYZxgpOutq2bwCrty0xAJtKO5uJUOkdCIFN9fsxr+Q4OMLdpvHgWhnYE6xnobJI2 UOmABAVbbw== Received-SPF: none client-ip=212.227.126.187; envelope-from=mail@bernhard-voelker.de; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: findutils-patches@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Patch submission list for GNU findutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2020 16:24:44 -0000 This is a multi-part message in MIME format. --------------4C6963BBFC02CA394EC64BA1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi *, some maintenance commits to use the gnulib *-safer wrappers more consistently which avoid some stdin/stdout/stderr abuse cases. * [PATCH 1/2] maint: use more *-safer gnulib modules * [PATCH 2/2] maint: use gnulib *_safer functions consistently Have a nice day, Berny --------------4C6963BBFC02CA394EC64BA1 Content-Type: text/x-patch; charset=UTF-8; name="0001-maint-use-more-safer-gnulib-modules.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-maint-use-more-safer-gnulib-modules.patch" >From 160e2f8258cb2a3f8cf055658b1840df5347bd6a Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 2 Dec 2020 01:12:16 +0100 Subject: [PATCH 1/2] maint: use more *-safer gnulib modules See section "Handling closed standard file descriptors" in the gnulib manual. * bootstrip.conf (gnulib_modules): Add fcntl-safer, openat-safer and unistd-safer. * find/exec.c: Include "fcntl--.h" to use the *-safer variant of open() or openat(). * find/pred.c: Likewise. * locate/locate.c: Likewise. * xargs/xargs.c: Likewise, and include "unustd--.h" to use the *-safer variant of pipe(). --- bootstrap.conf | 3 +++ find/exec.c | 1 + find/pred.c | 1 + locate/locate.c | 1 + xargs/xargs.c | 2 ++ 5 files changed, 8 insertions(+) diff --git a/bootstrap.conf b/bootstrap.conf index 8e0dbcf1..a80e2897 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -93,6 +93,7 @@ gnulib_modules=" faccessat fchdir fcntl + fcntl-safer fdopendir fflush fileblocks @@ -131,6 +132,7 @@ gnulib_modules=" mountlist nstrftime open + openat-safer parse-datetime pathmax perror @@ -167,6 +169,7 @@ gnulib_modules=" sys_wait timespec uname + unistd-safer unlinkat verify version-etc diff --git a/find/exec.c b/find/exec.c index 5551de56..e8f14d10 100644 --- a/find/exec.c +++ b/find/exec.c @@ -30,6 +30,7 @@ #include "cloexec.h" #include "dirname.h" #include "error.h" +#include "fcntl--.h" #include "save-cwd.h" #include "xalloc.h" diff --git a/find/pred.c b/find/pred.c index 9f2f159e..7a64a866 100644 --- a/find/pred.c +++ b/find/pred.c @@ -38,6 +38,7 @@ #include "areadlink.h" #include "dirname.h" #include "error.h" +#include "fcntl--.h" #include "fnmatch.h" #include "stat-size.h" #include "stat-time.h" diff --git a/locate/locate.c b/locate/locate.c index b3a49b84..bcd76103 100644 --- a/locate/locate.c +++ b/locate/locate.c @@ -84,6 +84,7 @@ #include "progname.h" #include "xalloc.h" #include "error.h" +#include "fcntl--.h" #include "human.h" #include "dirname.h" #include "closeout.h" diff --git a/xargs/xargs.c b/xargs/xargs.c index e9ef763c..1149999c 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -54,9 +54,11 @@ /* gnulib headers. */ #include "closein.h" #include "error.h" +#include "fcntl--.h" #include "progname.h" #include "quotearg.h" #include "safe-read.h" +#include "unistd--.h" #include "xalloc.h" /* find headers. */ -- 2.29.2 --------------4C6963BBFC02CA394EC64BA1 Content-Type: text/x-patch; charset=UTF-8; name="0002-maint-use-gnulib-_safer-functions-consistently.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-maint-use-gnulib-_safer-functions-consistently.patch" >From dc1a69f6dc484e9ca72507f15e940ce3d060376e Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 2 Dec 2020 02:00:01 +0100 Subject: [PATCH 2/2] maint: use gnulib *_safer functions consistently Avoid using fopen_safer and opendir_safer directly in favor of letting gnulib transparently doing the work via "dirent--.h" and "stdio--.h". * find/oldfind.c (dirent-safer.h): Replace include ... (dirent--.h): ... by this. (process_dir): Change opendir_safer to the regular opendir call. * find/sharefile.c (stdio-safer.h): Replace include ... (stdio--.h): ... by this. (sharefile_fopen): Change fopen_safer to regular fopen call. * lib/fdleak.c (dirent-safer.h): Replace include ... (dirent--.h): ... by this. (get_proc_max_fd): Change opendir_safer to regular opendir call. --- find/oldfind.c | 4 ++-- find/sharefile.c | 4 ++-- lib/fdleak.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/find/oldfind.c b/find/oldfind.c index d40bfb52..1da68037 100644 --- a/find/oldfind.c +++ b/find/oldfind.c @@ -35,7 +35,7 @@ /* gnulib headers. */ #include "canonicalize.h" #include "closein.h" -#include "dirent-safer.h" +#include "dirent--.h" #include "dirname.h" #include "error.h" #include "fcntl--.h" @@ -1304,7 +1304,7 @@ process_dir (const char *pathname, const char *name, int pathlen, const struct s } errno = 0; - dirp = opendir_safer (name); + dirp = opendir (name); if (dirp == NULL) { diff --git a/find/sharefile.c b/find/sharefile.c index 2b2bff72..384432ff 100644 --- a/find/sharefile.c +++ b/find/sharefile.c @@ -29,7 +29,7 @@ /* gnulib headers. */ #include "cloexec.h" #include "hash.h" -#include "stdio-safer.h" +#include "stdio--.h" /* find headers. */ #include "sharefile.h" @@ -154,7 +154,7 @@ sharefile_fopen (sharefile_handle h, const char *filename) return NULL; } - if (NULL == (new_entry->fp = fopen_safer (filename, p->mode))) + if (NULL == (new_entry->fp = fopen (filename, p->mode))) { entry_free (new_entry); return NULL; diff --git a/lib/fdleak.c b/lib/fdleak.c index 269c860d..7509b8f5 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -34,7 +34,7 @@ /* gnulib headers. */ #include "cloexec.h" -#include "dirent-safer.h" +#include "dirent--.h" #include "error.h" #include "fcntl--.h" @@ -66,7 +66,7 @@ get_proc_max_fd (void) * a given directory (the manpage for readdir_r claims this * is the approved method, but the manpage for pathconf indicates * that _PC_NAME_MAX is not an upper limit). */ - DIR *dir = opendir_safer (path); + DIR *dir = opendir (path); if (dir) { int good = 0; -- 2.29.2 --------------4C6963BBFC02CA394EC64BA1--