Skip to content

Commit d6f5cd3

Browse files
authored
chown: avoid getpwnam(undef)
* If the 1st argument (mode) of chown is an empty string, splitting the string results in an empty array * Terminate the program before calling getpwnam()
1 parent f2d8543 commit d6f5cd3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bin/chown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ while (@ARGV && $ARGV [0] =~ /^-/) {
5151
my $mode = shift;
5252
usage() unless @ARGV;
5353

54+
if (length($mode) == 0) {
55+
warn "$Program: invalid user: ''\n";
56+
exit EX_FAILURE;
57+
}
5458
my ($owner, $group) = split /:/ => $mode, 2;
5559

5660
my $uid = getpwnam $owner;

0 commit comments

Comments
 (0)