Commit f472eebd authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 099f4dd4
Pipeline #24927755 passed with stages
in 15 minutes and 33 seconds
......@@ -1841,23 +1841,23 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
mutt_perror (outfile);
return NULL;
}
mutt_mktemp (errfile, sizeof (errfile));
if ((smimeerr = safe_fopen (errfile, "w+")) == NULL)
{
mutt_perror (errfile);
safe_fclose (&smimeout); smimeout = NULL;
safe_fclose (&smimeout);
return NULL;
}
mutt_unlink (errfile);
mutt_mktemp (tmpfname, sizeof (tmpfname));
if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL)
{
mutt_perror (tmpfname);
safe_fclose (&smimeout); smimeout = NULL;
safe_fclose (&smimeerr); smimeerr = NULL;
safe_fclose (&smimeout);
safe_fclose (&smimeerr);
return NULL;
}
......@@ -1872,7 +1872,7 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
(thepid = smime_invoke_decrypt (&smimein, NULL, NULL, -1,
fileno (smimeout), fileno (smimeerr), tmpfname)) == -1)
{
safe_fclose (&smimeout); smimeout = NULL;
safe_fclose (&smimeout);
mutt_unlink (tmpfname);
if (s->flags & MUTT_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
......@@ -1883,14 +1883,14 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
fileno (smimeout), fileno (smimeerr), NULL,
tmpfname, SIGNOPAQUE)) == -1)
{
safe_fclose (&smimeout); smimeout = NULL;
safe_fclose (&smimeout);
mutt_unlink (tmpfname);
if (s->flags & MUTT_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
return NULL;
}
if (type & ENCRYPT)
{
if (!smime_valid_passphrase ())
......@@ -1900,25 +1900,25 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
}
safe_fclose (&smimein);
mutt_wait_filter (thepid);
mutt_unlink (tmpfname);
if (s->flags & MUTT_DISPLAY)
{
fflush (smimeerr);
rewind (smimeerr);
if ((c = fgetc (smimeerr)) != EOF)
{
ungetc (c, smimeerr);
crypt_current_time (s, "OpenSSL");
mutt_copy_stream (smimeerr, s->fpout);
state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s);
}
if (type & ENCRYPT)
state_attach_puts (_("[-- The following data is S/MIME"
" encrypted --]\n"), s);
......@@ -1926,74 +1926,70 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
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_void_passphrase ();
}
rewind (smimeout);
mutt_error _("Decryption failed");
smime_void_passphrase ();
}
if (outFile) fpout = outFile;
else
rewind (smimeout);
}
if (outFile) fpout = outFile;
else
{
mutt_mktemp (tmptmpfname, sizeof (tmptmpfname));
if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL)
{
mutt_mktemp (tmptmpfname, sizeof (tmptmpfname));
if ((fpout = safe_fopen (tmptmpfname, "w+")) == NULL)
{
mutt_perror(tmptmpfname);
safe_fclose (&smimeout); smimeout = NULL;
return NULL;
}
mutt_perror(tmptmpfname);
safe_fclose (&smimeout);
return NULL;
}
while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL)
}
while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL)
{
len = mutt_strlen (buf);
if (len > 1 && buf[len - 2] == '\r')
{
len = mutt_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);
fputs (buf, fpout);
}
fflush (fpout);
rewind (fpout);
if ((p = mutt_read_mime_header (fpout, 0)) != NULL)
{
fstat (fileno (fpout), &info);
p->length = info.st_size - p->offset;
if ((p = mutt_read_mime_header (fpout, 0)) != NULL)
mutt_parse_part (fpout, p);
if (s->fpout)
{
fstat (fileno (fpout), &info);
p->length = info.st_size - p->offset;
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;
}
rewind (fpout);
tmpfp_buffer = s->fpin;
s->fpin = fpout;
mutt_body_handler (p, s);
s->fpin = tmpfp_buffer;
}
safe_fclose (&smimeout);
smimeout = NULL;
mutt_unlink (outfile);
}
if (!outFile)
{
safe_fclose (&fpout);
mutt_unlink (tmptmpfname);
}
fpout = NULL;
safe_fclose (&smimeout);
mutt_unlink (outfile);
if (!outFile)
{
safe_fclose (&fpout);
mutt_unlink (tmptmpfname);
}
fpout = NULL;
if (s->flags & MUTT_DISPLAY)
{
......@@ -2008,15 +2004,15 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
char *line = NULL;
int lineno = 0;
size_t linelen;
rewind (smimeerr);
line = mutt_read_line (line, &linelen, smimeerr, &lineno, 0);
if (linelen && !ascii_strcasecmp (line, "verification successful"))
m->goodsig = 1;
FREE (&line);
}
else
else
{
m->goodsig = p->goodsig;
m->badsig = p->badsig;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment