diff options
author | Dave Borowitz <dborowitz@google.com> | 2015-07-01 11:44:09 -0700 |
---|---|---|
committer | Dave Borowitz <dborowitz@google.com> | 2015-07-09 11:05:45 -0700 |
commit | 8293c770b5289eb89753a319c3c22217627200a0 (patch) | |
tree | 7c8383c1b83f548134d64fdf9fc919bafe197399 /org.eclipse.jgit | |
parent | f22f33f5bfbfb616a59006ac7bcb3810fdac4619 (diff) | |
download | jgit-8293c770b5289eb89753a319c3c22217627200a0.tar.gz jgit-8293c770b5289eb89753a319c3c22217627200a0.zip |
PushCertificateParser: Make pushee optional
When pushing to an HTTP server using the C git client, I observed a
certificate lacking a pushee field. Handle this gracefully in the
parser.
Change-Id: I7f3c5fa78f2e35172a93180036e679687415cac4
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java | 4 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java index fdc70adc88..165a93908d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java @@ -98,10 +98,6 @@ public class PushCertificate { throw new IllegalArgumentException(MessageFormat.format( JGitText.get().pushCertificateInvalidField, PUSHER)); } - if (pushee == null || pushee.isEmpty()) { - throw new IllegalArgumentException(MessageFormat.format( - JGitText.get().pushCertificateInvalidField, PUSHEE)); - } if (nonce == null || nonce.isEmpty()) { throw new IllegalArgumentException(MessageFormat.format( JGitText.get().pushCertificateInvalidField, NONCE)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java index 1bc73bb3ed..6494aea63e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java @@ -273,7 +273,11 @@ public class PushCertificateParser { private static String parseHeader(StringReader reader, String header) throws IOException { - String s = reader.read(); + return parseHeader(reader.read(), header); + } + + private static String parseHeader(String s, String header) + throws IOException { if (s.isEmpty()) { throw new EOFException(); } @@ -331,8 +335,13 @@ public class PushCertificateParser { JGitText.get().pushCertificateInvalidFieldValue, PUSHER, rawPusher)); } - pushee = parseHeader(reader, PUSHEE); - receivedNonce = parseHeader(reader, NONCE); + String next = reader.read(); + if (next.startsWith(PUSHEE)) { + pushee = parseHeader(next, PUSHEE); + receivedNonce = parseHeader(reader, NONCE); + } else { + receivedNonce = parseHeader(next, NONCE); + } nonceStatus = nonceGenerator != null ? nonceGenerator.verify( receivedNonce, sentNonce(), db, stateless, nonceSlopLimit) |