All of lore.kernel.org
 help / color / mirror / Atom feed
From: mw-u2@gmx.de
To: git@vger.kernel.org
Subject: Bug: git svn sends password + "\n" on windows
Date: Fri, 06 Jul 2012 09:39:08 +0200	[thread overview]
Message-ID: <20120706073908.278660@gmx.net> (raw)

Hi,

please go easy on me, this is my first bug report. I hope this is the right
place to post.

Problem: When using SshAskPass (from TortoiseGit, on Windows), git svn clone
fails with 

| git.exe svn clone "http://xxx/svn/Project"  "D:\Project"
| 
| Initialized empty Git repository in d:/Project/.git/
| Authentication realm: <http://xxx:80> Subversion Repository
| Authentication realm: <http://dew132:80> Subversion Repository
| Username: Use of uninitialized value in chomp at C:\Program Files\Git/libexec/git-core\git-svn line 4417.
| 0 [main] perl.exe" 7200 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
| 433 [main] perl.exe" 7200 open_stackdumpfile: Dumping stack trace to perl.exe.stackdump
| 
| git did not exit cleanly (exit code -1)

I have verified that the git svn client sends the base64 encoded string
"password" + "\n" as http header:
| Authorization: Basic dGVzdAo=
(Which should decode to "test\n". I had to replace my password with a manual
encoded version to show to you.)

I think there is a bug/issue in perl/Git/SVN/Prompt.pm. On windows only "\r" of
"\r\n" gets removed after calling GIT_ASKPASS. I have changed, 

diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index 3a6f8af..8f49457 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -124,7 +124,7 @@ sub _read_password {
 	if (exists $ENV{GIT_ASKPASS}) {
 		open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt);
 		$password = <PH>;
-		$password =~ s/[\012\015]//; # \n\r
+		$password =~ s/[\012\015][\012\015]?//; # \n\r
 		close(PH);
 	} else {
 		print STDERR $prompt;

and the clone worked, but think one should chomp (as sub username does):

diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index 3a6f8af..30b6256 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -123,8 +123,7 @@ sub _read_password {
 	my $password = '';
 	if (exists $ENV{GIT_ASKPASS}) {
 		open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt);
-		$password = <PH>;
-		$password =~ s/[\012\015]//; # \n\r
+		chomp($password = <PH>);
 		close(PH);
 	} else {
 		print STDERR $prompt;

Unfortunately I could not test the 2nd version, because somehow git saves the
successful credentials and I have not researched/found out, how to reset that
information yet.

Thanks for your consideration
Micha Wiedenmann

Versions:
TortoiseGit 1.7.10.0 
git version 1.7.10.msysgit.1 

                 reply	other threads:[~2012-07-06  7:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120706073908.278660@gmx.net \
    --to=mw-u2@gmx.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.