projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add an assortment of extra safety checks.
[u/mdw/putty]
/
sshpubk.c
diff --git
a/sshpubk.c
b/sshpubk.c
index
c29d8a5
..
bd3c5e4
100644
(file)
--- a/
sshpubk.c
+++ b/
sshpubk.c
@@
-257,8
+257,8
@@
int rsakey_pubblob(const Filename *filename, void **blob, int *bloblen,
*blob = rsa_public_blob(&key, bloblen);
freersakey(&key);
ret = 1;
*blob = rsa_public_blob(&key, bloblen);
freersakey(&key);
ret = 1;
- fp = NULL;
}
}
+ fp = NULL; /* loadrsakey_main unconditionally closes fp */
} else {
error = "not an SSH-1 RSA file";
}
} else {
error = "not an SSH-1 RSA file";
}
@@
-647,6
+647,11
@@
struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
/* this is an old key file; warn and then continue */
old_keyfile_warning();
old_fmt = 1;
/* this is an old key file; warn and then continue */
old_keyfile_warning();
old_fmt = 1;
+ } else if (0 == strncmp(header, "PuTTY-User-Key-File-", 20)) {
+ /* this is a key file FROM THE FUTURE; refuse it, but with a
+ * more specific error message than the generic one below */
+ error = "PuTTY key format too new";
+ goto error;
} else {
error = "not a PuTTY SSH-2 private key";
goto error;
} else {
error = "not a PuTTY SSH-2 private key";
goto error;
@@
-674,7
+679,6
@@
struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
cipher = 0;
cipherblk = 1;
} else {
cipher = 0;
cipherblk = 1;
} else {
- sfree(encryption);
goto error;
}
goto error;
}
@@
-891,7
+895,10
@@
unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm,
if (!read_header(fp, header)
|| (0 != strcmp(header, "PuTTY-User-Key-File-2") &&
0 != strcmp(header, "PuTTY-User-Key-File-1"))) {
if (!read_header(fp, header)
|| (0 != strcmp(header, "PuTTY-User-Key-File-2") &&
0 != strcmp(header, "PuTTY-User-Key-File-1"))) {
- error = "not a PuTTY SSH-2 private key";
+ if (0 == strncmp(header, "PuTTY-User-Key-File-", 20))
+ error = "PuTTY key format too new";
+ else
+ error = "not a PuTTY SSH-2 private key";
goto error;
}
error = "file format error";
goto error;
}
error = "file format error";