]> source.dussan.org Git - jgit.git/commitdiff
BaseReceivePack: fix reading cert lines in command loop 93/50293/4
authorDave Borowitz <dborowitz@google.com>
Mon, 15 Jun 2015 18:54:13 +0000 (14:54 -0400)
committerDave Borowitz <dborowitz@google.com>
Thu, 18 Jun 2015 13:50:11 +0000 (09:50 -0400)
Add a missing continues to prevent falling through to the command
parsing section. The first continue happens when the command list is
empty, so change the condition to see whether we have read the first
line, rather than any commands.

Fix comparison to BEGIN_SIGNATURE to use raw line with newline.

Change-Id: If3d92f5ceade8ba7605847a4b2bc55ff17d119ac

org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

index 111a227344726af01630fe6c0f44a146049eea58..63b9bbbd384eec2e101a9f3fce7330e37a2d5dde 100644 (file)
@@ -1043,6 +1043,7 @@ public abstract class BaseReceivePack {
         * @throws IOException
         */
        protected void recvCommands() throws IOException {
+               FirstLine firstLine = null;
                for (;;) {
                        String rawLine;
                        try {
@@ -1062,18 +1063,21 @@ public abstract class BaseReceivePack {
                                continue;
                        }
 
-                       if (commands.isEmpty()) {
-                               final FirstLine firstLine = new FirstLine(line);
+                       if (firstLine == null) {
+                               firstLine = new FirstLine(line);
                                enabledCapabilities = firstLine.getCapabilities();
                                line = firstLine.getLine();
 
-                               if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT))
+                               if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) {
                                        pushCertificateParser.receiveHeader(pckIn,
                                                        !isBiDirectionalPipe());
+                                       continue;
+                               }
                        }
 
-                       if (line.equals(PushCertificateParser.BEGIN_SIGNATURE)) {
+                       if (rawLine.equals(PushCertificateParser.BEGIN_SIGNATURE)) {
                                pushCertificateParser.receiveSignature(pckIn);
+                               continue;
                        }
 
                        if (line.length() < 83) {