зеркало из https://github.com/github/putty.git
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:
Родитель
35a4283615
Коммит
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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче