commit: 9714dcb294083d70baa2f55769a55ef1c2f80b32
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jan 10 01:51:21 2026 +0000
Commit: Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Sat Jan 10 01:51:21 2026 +0000
URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=9714dcb2
Check against /dev/{null,stdin} intelligently in fopen()
Presently, the fopen() subroutine rejects pathnames that do not refer to
regular files, with the exception of /dev/null and /dev/stdin. However,
it checks against the latter two pathnames in a stringwise fashion,
which is not strictly correct.
# cd /dev && locale-gen -c null
locale-gen: Won't open 'null' because it is not a regular file
Address this issue by using the is_eq_file() subroutine to compare the
pathnames.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
locale-gen | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/locale-gen b/locale-gen
index 1cf6a5c..097e423 100644
--- a/locale-gen
+++ b/locale-gen
@@ -11,7 +11,7 @@ use Errno qw(ENOENT);
use File::Spec::Functions qw(canonpath catfile catdir path splitpath);
use File::Temp qw(tempdir);
use Getopt::Long ();
-use List::Util qw(all any first min);
+use List::Util qw(all any first min none);
use Term::ANSIColor qw(colored);
# Formally stable as of v5.40; sufficiently functional in both v5.36 and v5.38.
@@ -656,7 +656,7 @@ sub copy_security_context ($src_path, $dst_path) {
sub fopen ($path) {
if (! open my $fh, '<', $path) {
die "$PROGRAM: Can't open '$path': $!\n";
- } elsif (! -f $fh && canonpath($path) !~ m/^\/dev\/(null|stdin)\z/n) {
+ } elsif (! -f $fh && none(sub { is_eq_file($path, $_) }, '/dev/null',
'/dev/stdin')) {
die "$PROGRAM: Won't open '$path' because it is not a regular
file\n";
} else {
return $fh;