mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 09:12:24 +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:
parent
35a4283615
commit
b9bfc81531
18
cmdgen.c
18
cmdgen.c
@ -959,10 +959,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (outfile)
|
if (outfile) {
|
||||||
fp = f_open(outfilename, "w", FALSE);
|
fp = f_open(outfilename, "w", FALSE);
|
||||||
else
|
if (!fp) {
|
||||||
|
fprintf(stderr, "unable to open output file\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
|
}
|
||||||
|
|
||||||
if (sshver == 1) {
|
if (sshver == 1) {
|
||||||
ssh1_write_pubkey(fp, ssh1key);
|
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);
|
fp = f_open(outfilename, "w", FALSE);
|
||||||
else
|
if (!fp) {
|
||||||
|
fprintf(stderr, "unable to open output file\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
|
}
|
||||||
fprintf(fp, "%s\n", fingerprint);
|
fprintf(fp, "%s\n", fingerprint);
|
||||||
if (outfile)
|
if (outfile)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user