1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

cmdgen: fix segfault on failing to open the output file.

D'oh - simply forgot to check the return value of fopen for NULL.
This commit is contained in:
Simon Tatham 2018-10-15 22:26:20 +01:00
parent 35a4283615
commit b9bfc81531

View File

@ -959,10 +959,15 @@ int main(int argc, char **argv)
{
FILE *fp;
if (outfile)
if (outfile) {
fp = f_open(outfilename, "w", FALSE);
else
if (!fp) {
fprintf(stderr, "unable to open output file\n");
exit(1);
}
} else {
fp = stdout;
}
if (sshver == 1) {
ssh1_write_pubkey(fp, ssh1key);
@ -1003,10 +1008,15 @@ int main(int argc, char **argv)
}
}
if (outfile)
if (outfile) {
fp = f_open(outfilename, "w", FALSE);
else
if (!fp) {
fprintf(stderr, "unable to open output file\n");
exit(1);
}
} else {
fp = stdout;
}
fprintf(fp, "%s\n", fingerprint);
if (outfile)
fclose(fp);