unbreak parsing of pubkey comments; with gerhard; ok djm/deraadt
authormarkus <markus@openbsd.org>
Mon, 12 Jan 2015 20:13:27 +0000 (20:13 +0000)
committermarkus <markus@openbsd.org>
Mon, 12 Jan 2015 20:13:27 +0000 (20:13 +0000)
regress/usr.bin/ssh/Makefile
usr.bin/ssh/sshkey.c

index e930741..0699082 100644 (file)
@@ -1,10 +1,11 @@
-#      $OpenBSD: Makefile,v 1.72 2014/12/22 08:06:03 djm Exp $
+#      $OpenBSD: Makefile,v 1.73 2015/01/12 20:13:27 markus Exp $
 
 REGRESS_FAIL_EARLY= yes
-REGRESS_TARGETS=       unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11
+REGRESS_TARGETS=       unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12
 
 CLEANFILES+=   t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
-               t8.out t8.out.pub t9.out t9.out.pub
+               t8.out t8.out.pub t9.out t9.out.pub t10.out t10.out.pub \
+               t12.out t12.out.pub
 
 LTESTS=        connect \
                proxy-connect \
@@ -154,6 +155,12 @@ t11:
        ssh-keygen -E sha256 -lf ${.CURDIR}/rsa_openssh.pub |\
                awk '{print $$2}' | diff - ${.CURDIR}/t11.ok
 
+t12.out:
+       ssh-keygen -q -t ed25519 -N '' -C 'test-comment-1234' -f $@
+
+t12: t12.out
+       ssh-keygen -lf t12.out.pub | grep -q test-comment-1234
+
 modpipe: modpipe.c
 
 t-integrity: modpipe
index 4421bff..1fd3136 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshkey.c,v 1.9 2015/01/12 13:29:27 markus Exp $ */
+/* $OpenBSD: sshkey.c,v 1.10 2015/01/12 20:13:27 markus Exp $ */
 /*
  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
  * Copyright (c) 2008 Alexander von Gernler.  All rights reserved.
@@ -1251,8 +1251,14 @@ sshkey_read(struct sshkey *ret, char **cpp)
                        return SSH_ERR_ALLOC_FAIL;
                /* trim comment */
                space = strchr(cp, ' ');
-               if (space)
-                       *space = '\0';
+               if (space) {
+                       /* advance 'space': skip whitespace */
+                       *space++ = '\0';
+                       while (*space == ' ' || *space == '\t')
+                               space++;
+                       *cpp = space;
+               } else
+                       *cpp = cp + strlen(cp);
                if ((r = sshbuf_b64tod(blob, cp)) != 0) {
                        sshbuf_free(blob);
                        return r;
@@ -1327,12 +1333,6 @@ sshkey_read(struct sshkey *ret, char **cpp)
                sshkey_free(k);
                if (retval != 0)
                        break;
-               /* advance cp: skip whitespace and data */
-               while (*cp == ' ' || *cp == '\t')
-                       cp++;
-               while (*cp != '\0' && *cp != ' ' && *cp != '\t')
-                       cp++;
-               *cpp = cp;
                break;
        default:
                return SSH_ERR_INVALID_ARGUMENT;