summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-03-27 12:33:36 +0000
committerschwarze <schwarze@openbsd.org>2015-03-27 12:33:36 +0000
commite4edfe2a77ec509a9c11d5d2077fc949c324b159 (patch)
treef6a09ad2b93622c6666b504d4d71481cebec5b69
parentFactor out the init_buf initialisation code, rather than duplicating it (diff)
downloadwireguard-openbsd-e4edfe2a77ec509a9c11d5d2077fc949c324b159.tar.xz
wireguard-openbsd-e4edfe2a77ec509a9c11d5d2077fc949c324b159.zip
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@
-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;
}