From: Mark Wooding Date: Mon, 13 Aug 2018 20:30:07 +0000 (+0100) Subject: progs/catsign.c: Don't gratuitously try to open a temporary file. X-Git-Tag: 2.4.3~15 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb/commitdiff_plain/2921991916ba2362d054111a0d041ff170c899c1 progs/catsign.c: Don't gratuitously try to open a temporary file. The `merry dance' where we open the necessary output files was bungled, which caused a temporary file to be opened unless an explicit output file was requested without buffering. --- diff --git a/progs/catsign.c b/progs/catsign.c index accd592f..3cce9c93 100644 --- a/progs/catsign.c +++ b/progs/catsign.c @@ -749,14 +749,14 @@ static int verify(int argc, char *argv[]) } else if (!of || strcmp(of, "-") == 0) { v.f |= F_BUFFER; ofp = stdout; - } - if (of && !(v.f & F_BUFFER)) { + } else if (of && !(v.f & F_BUFFER)) { if ((ofp = fopen(of, (v.f & F_BINARY) ? "wb" : "w")) == 0) { die(EXIT_FAILURE, "couldn't open file `%s' for output: %s", of, strerror(errno)); } rfp = ofp; - } else if ((rfp = tmpfile()) == 0) + } + if ((v.f & F_BUFFER) && (rfp = tmpfile()) == 0) die(EXIT_FAILURE, "couldn't create temporary file: %s", strerror(errno)); /* --- Read the message and verify the signature --- */