From: Kevin McCarthy Date: Mon, 2 Jul 2018 03:43:24 +0000 (-0700) Subject: smime_handle_entity() cleanup X-Git-Tag: 2019-10-25~671^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2ae44b8cfa469cba63a14f30c819d2c5a3e6928;p=neomutt smime_handle_entity() cleanup Remove redundant NULL assignments after safe_fclose() calls. Remove some trailing spaces. smimeout can't be NULL, so remove the check around the output translation block. --- diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 815742cc7..91c7b766c 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -2113,74 +2113,70 @@ static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *o state_attach_puts(_("[-- The following data is S/MIME signed --]\n"), s); } - if (smimeout) - { - fflush(smimeout); - rewind(smimeout); + fflush(smimeout); + rewind(smimeout); - if (type & ENCRYPT) + if (type & ENCRYPT) + { + /* void the passphrase, even if that wasn't the problem */ + if (fgetc(smimeout) == EOF) { - /* void the passphrase, even if that wasn't the problem */ - if (fgetc(smimeout) == EOF) - { - mutt_error(_("Decryption failed")); - smime_class_void_passphrase(); - } - rewind(smimeout); + mutt_error(_("Decryption failed")); + smime_class_void_passphrase(); } + rewind(smimeout); + } - if (out_file) - fpout = out_file; - else + if (out_file) + fpout = out_file; + else + { + fpout = mutt_file_mkstemp(); + if (!fpout) { - fpout = mutt_file_mkstemp(); - if (!fpout) - { - mutt_perror(_("Can't create temporary file")); - mutt_file_fclose(&smimeout); - mutt_file_fclose(&smimeerr); - return NULL; - } + mutt_perror(_("Can't create temporary file")); + mutt_file_fclose(&smimeout); + mutt_file_fclose(&smimeerr); + return NULL; } - char buf[HUGE_STRING]; - while (fgets(buf, sizeof(buf) - 1, smimeout)) + } + char buf[HUGE_STRING]; + while (fgets(buf, sizeof(buf) - 1, smimeout)) + { + const size_t len = mutt_str_strlen(buf); + if (len > 1 && buf[len - 2] == '\r') { - const size_t len = mutt_str_strlen(buf); - if (len > 1 && buf[len - 2] == '\r') - { - buf[len - 2] = '\n'; - buf[len - 1] = '\0'; - } - fputs(buf, fpout); + buf[len - 2] = '\n'; + buf[len - 1] = '\0'; } - fflush(fpout); - rewind(fpout); - - p = mutt_read_mime_header(fpout, 0); - if (p) - { - fstat(fileno(fpout), &info); - p->length = info.st_size - p->offset; + fputs(buf, fpout); + } + fflush(fpout); + rewind(fpout); - mutt_parse_part(fpout, p); - if (s->fpout) - { - rewind(fpout); - tmpfp_buffer = s->fpin; - s->fpin = fpout; - mutt_body_handler(p, s); - s->fpin = tmpfp_buffer; - } - } - mutt_file_fclose(&smimeout); - smimeout = NULL; + p = mutt_read_mime_header(fpout, 0); + if (p) + { + fstat(fileno(fpout), &info); + p->length = info.st_size - p->offset; - if (!out_file) + mutt_parse_part(fpout, p); + if (s->fpout) { - mutt_file_fclose(&fpout); + rewind(fpout); + tmpfp_buffer = s->fpin; + s->fpin = fpout; + mutt_body_handler(p, s); + s->fpin = tmpfp_buffer; } - fpout = NULL; } + mutt_file_fclose(&smimeout); + + if (!out_file) + { + mutt_file_fclose(&fpout); + } + fpout = NULL; if (s->flags & MUTT_DISPLAY) {