Skip to content

Commit 53ca382

Browse files
Maxim Cournoyergitster
authored andcommitted
contrib: warn for invalid netrc file ports in git-credential-netrc
Invalid ports were previously silently dropped; now a warning message is produced. Signed-off-by: Maxim Cournoyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3570fba commit 53ca382

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

contrib/credential/netrc/git-credential-netrc.perl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,14 @@ sub load_netrc {
267267
if (!defined $nentry->{machine}) {
268268
next;
269269
}
270-
if (defined $nentry->{port} && $nentry->{port} =~ m/^\d+$/) {
271-
$num_port = $nentry->{port};
272-
delete $nentry->{port};
270+
if (defined $nentry->{port}) {
271+
if ($nentry->{port} =~ m/^\d+$/) {
272+
$num_port = $nentry->{port};
273+
delete $nentry->{port};
274+
} else {
275+
printf(STDERR "ignoring invalid port `%s' " .
276+
"from netrc file\n", $nentry->{port});
277+
}
273278
}
274279

275280
# create the new entry for the credential helper protocol

0 commit comments

Comments
 (0)