summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-03-27 12:33:37 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-03-27 12:33:37 +0000
commitd4b4e43a2da2bea0b3913f8d41d3bb3869ef3ae5 (patch)
tree0d49f69bb2552f41140179ba615d617d6f2edd63 /libexec
parent5010855606fae1195c13b0ca26d1b242870ece3a (diff)
If /etc/passwd contains incomplete lines ending before the
home directory field, warn explicitly rather than stumbling into Perl "uninitialized value" warnings. Issue reported by Denis Lapshin <deniza at mindall dot org>. OK afresh1@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/security/security15
1 files changed, 12 insertions, 3 deletions
diff --git a/libexec/security/security b/libexec/security/security
index 5ebeaeecaa6..2c1ef689d57 100644
--- a/libexec/security/security
+++ b/libexec/security/security
@@ -1,8 +1,8 @@
#!/usr/bin/perl -T
-# $OpenBSD: security,v 1.32 2014/12/04 00:07:21 schwarze Exp $
+# $OpenBSD: security,v 1.33 2015/03/27 12:33:36 schwarze Exp $
#
-# Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2011, 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@@ -336,7 +336,16 @@ sub find_homes {
nag !(open my $fh, '<', $filename),
"open: $filename: $!"
and return [];
- my $homes = [ map [ @{[split /:/]}[0,2,5] ], <$fh> ];
+ my $homes = [];
+ while (<$fh>) {
+ my $entry = [ @{[split /:/]}[0,2,5] ];
+ chomp;
+ nag !defined $entry->[2],
+ "Incomplete line \"$_\" in $filename."
+ and next;
+ chomp $entry->[2];
+ push @$homes, $entry;
+ }
close $fh;
return $homes;
}