projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Martin Prikryl points out that need_pw may be used uninitialised.
[u/mdw/putty]
/
sshpubk.c
diff --git
a/sshpubk.c
b/sshpubk.c
index
3975e0f
..
f87a081
100644
(file)
--- a/
sshpubk.c
+++ b/
sshpubk.c
@@
-182,6
+182,9
@@
int loadrsakey(const Filename *filename, struct RSAKey *key, char *passphrase,
* key file.
*/
if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) {
* key file.
*/
if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) {
+ /*
+ * This routine will take care of calling fclose() for us.
+ */
ret = loadrsakey_main(fp, key, FALSE, NULL, passphrase, &error);
goto end;
}
ret = loadrsakey_main(fp, key, FALSE, NULL, passphrase, &error);
goto end;
}
@@
-189,10
+192,10
@@
int loadrsakey(const Filename *filename, struct RSAKey *key, char *passphrase,
/*
* Otherwise, we have nothing. Return empty-handed.
*/
/*
* Otherwise, we have nothing. Return empty-handed.
*/
- fclose(fp);
error = "not an SSH-1 RSA file";
end:
error = "not an SSH-1 RSA file";
end:
+ fclose(fp);
if ((ret != 1) && errorstr)
*errorstr = error;
return ret;
if ((ret != 1) && errorstr)
*errorstr = error;
return ret;
@@
-217,6
+220,9
@@
int rsakey_encrypted(const Filename *filename, char **comment)
*/
if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) {
const char *dummy;
*/
if (fgets(buf, sizeof(buf), fp) && !strcmp(buf, rsa_signature)) {
const char *dummy;
+ /*
+ * This routine will take care of calling fclose() for us.
+ */
return loadrsakey_main(fp, NULL, FALSE, comment, NULL, &dummy);
}
fclose(fp);
return loadrsakey_main(fp, NULL, FALSE, comment, NULL, &dummy);
}
fclose(fp);
@@
-261,10
+267,11
@@
int rsakey_pubblob(const Filename *filename, void **blob, int *bloblen,
}
} else {
error = "not an SSH-1 RSA file";
}
} else {
error = "not an SSH-1 RSA file";
- fclose(fp);
}
end:
}
end:
+ if (fp)
+ fclose(fp);
if ((ret != 1) && errorstr)
*errorstr = error;
return ret;
if ((ret != 1) && errorstr)
*errorstr = error;
return ret;
@@
-433,8
+440,7
@@
int saversakey(const Filename *filename, struct RSAKey *key, char *passphrase)
* data "putty-private-key-file-mac-key"
* data passphrase
*
* data "putty-private-key-file-mac-key"
* data passphrase
*
- * Encrypted keys should have a MAC, whereas unencrypted ones must
- * have a hash.
+ * (An empty passphrase is used for unencrypted keys.)
*
* If the key is encrypted, the encryption key is derived from the
* passphrase by means of a succession of SHA-1 hashes. Each hash
*
* If the key is encrypted, the encryption key is derived from the
* passphrase by means of a succession of SHA-1 hashes. Each hash
@@
-836,7
+842,8
@@
struct ssh2_userkey *ssh2_load_userkey(const Filename *filename,
sfree(public_blob);
sfree(private_blob);
sfree(encryption);
sfree(public_blob);
sfree(private_blob);
sfree(encryption);
- *errorstr = NULL;
+ if (errorstr)
+ *errorstr = NULL;
return ret;
/*
return ret;
/*