]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix enum-conflation in cmdgen.c.
authorSimon Tatham <anakin@pobox.com>
Tue, 28 Apr 2015 18:46:08 +0000 (19:46 +0100)
committerSimon Tatham <anakin@pobox.com>
Tue, 28 Apr 2015 18:46:08 +0000 (19:46 +0100)
I'd somehow managed to declare an enum in cmdgen.c with key types
OPENSSH and SSHCOM, and use it interchangeably with the one in ssh.h
with SSH_KEYTYPE_OPENSSH and SSH_KEYTYPE_SSHCOM.

It so happened that the relevant two enum values matched up! So this
hasn't caused a bug yet, but it's an accident waiting to happen. Fix
it before it does.

cmdgen.c

index 80e69b5a7eaf331ef68232626a10009c6f5fbabd..e5a43c1fc28442d1bf67571c046dd90f8ccd2705 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -920,7 +920,7 @@ int main(int argc, char **argv)
        outfilename = filename_from_str(outfile ? outfile : "");
 
     switch (outtype) {
-       int ret;
+       int ret, real_outtype;
 
       case PRIVATE:
        if (sshver == 1) {
@@ -1058,7 +1058,15 @@ int main(int argc, char **argv)
        assert(ssh2key);
        random_ref(); /* both foreign key types require randomness,
                        * for IV or padding */
-       ret = export_ssh2(outfilename, outtype, ssh2key, passphrase);
+        switch (outtype) {
+          case OPENSSH:
+            real_outtype = SSH_KEYTYPE_OPENSSH;
+            break;
+          case SSHCOM:
+            real_outtype = SSH_KEYTYPE_SSHCOM;
+            break;
+        }
+       ret = export_ssh2(outfilename, real_outtype, ssh2key, passphrase);
        if (!ret) {
            fprintf(stderr, "puttygen: unable to export key\n");
            return 1;