]> git.ipfire.org Git - thirdparty/git.git/commitdiff
contrib: warn for invalid netrc file ports in git-credential-netrc
authorMaxim Cournoyer <maxim@guixotic.coop>
Tue, 24 Jun 2025 01:48:56 +0000 (10:48 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Jun 2025 16:05:34 +0000 (09:05 -0700)
Invalid ports were previously silently dropped; now a warning message
is produced.

Signed-off-by: Maxim Cournoyer <maxim@guixotic.coop>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/credential/netrc/git-credential-netrc.perl

index 514f68d00be72a86ce62c93f7c5d4c50489e1311..09d77b4f69380b376a840cce0499567693a5718c 100755 (executable)
@@ -267,9 +267,14 @@ sub load_netrc {
                if (!defined $nentry->{machine}) {
                        next;
                }
-               if (defined $nentry->{port} && $nentry->{port} =~ m/^\d+$/) {
-                       $num_port = $nentry->{port};
-                       delete $nentry->{port};
+               if (defined $nentry->{port}) {
+                       if ($nentry->{port} =~ m/^\d+$/) {
+                               $num_port = $nentry->{port};
+                               delete $nentry->{port};
+                       } else {
+                               printf(STDERR "ignoring invalid port `%s' " .
+                                      "from netrc file\n", $nentry->{port});
+                       }
                }
 
                # create the new entry for the credential helper protocol