]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - sshpubk.c
Add some index terms for host key overrides.
[PuTTY.git] / sshpubk.c
index b860040dbfbe55f321978a8c2b0d8c6fdead895f..cf9e44b365e1da223e4ac369e34a825ca45c3ae0 100644 (file)
--- a/sshpubk.c
+++ b/sshpubk.c
@@ -67,12 +67,13 @@ static int loadrsakey_main(FILE * fp, struct RSAKey *key, int pub_only,
     i += 4;
 
     /* Now the serious stuff. An ordinary SSH-1 public key. */
-    i += makekey(buf + i, len, key, NULL, 1);
-    if (i < 0)
+    = makekey(buf + i, len, key, NULL, 1);
+    if (j < 0)
        goto end;                      /* overran */
+    i += j;
 
     /* Next, the comment field. */
-    j = GET_32BIT(buf + i);
+    j = toint(GET_32BIT(buf + i));
     i += 4;
     if (j < 0 || len - i < j)
        goto end;
@@ -462,7 +463,7 @@ static int read_header(FILE * fp, char *header)
     int len = 39;
     int c;
 
-    while (len > 0) {
+    while (1) {
        c = fgetc(fp);
        if (c == '\n' || c == '\r' || c == EOF)
            return 0;                  /* failure */
@@ -512,54 +513,6 @@ static char *read_body(FILE * fp)
     }
 }
 
-int base64_decode_atom(char *atom, unsigned char *out)
-{
-    int vals[4];
-    int i, v, len;
-    unsigned word;
-    char c;
-
-    for (i = 0; i < 4; i++) {
-       c = atom[i];
-       if (c >= 'A' && c <= 'Z')
-           v = c - 'A';
-       else if (c >= 'a' && c <= 'z')
-           v = c - 'a' + 26;
-       else if (c >= '0' && c <= '9')
-           v = c - '0' + 52;
-       else if (c == '+')
-           v = 62;
-       else if (c == '/')
-           v = 63;
-       else if (c == '=')
-           v = -1;
-       else
-           return 0;                  /* invalid atom */
-       vals[i] = v;
-    }
-
-    if (vals[0] == -1 || vals[1] == -1)
-       return 0;
-    if (vals[2] == -1 && vals[3] != -1)
-       return 0;
-
-    if (vals[3] != -1)
-       len = 3;
-    else if (vals[2] != -1)
-       len = 2;
-    else
-       len = 1;
-
-    word = ((vals[0] << 18) |
-           (vals[1] << 12) | ((vals[2] & 0x3F) << 6) | (vals[3] & 0x3F));
-    out[0] = (word >> 16) & 0xFF;
-    if (len > 1)
-       out[1] = (word >> 8) & 0xFF;
-    if (len > 2)
-       out[2] = word & 0xFF;
-    return len;
-}
-
 static unsigned char *read_blob(FILE * fp, int nlines, int *bloblen)
 {
     unsigned char *blob;
@@ -1007,6 +960,8 @@ int ssh2_userkey_encrypted(const Filename *filename, char **commentptr)
 
     if (commentptr)
        *commentptr = comment;
+    else
+        sfree(comment);
 
     fclose(fp);
     if (!strcmp(b, "aes256-cbc"))