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;
}
(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);
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 ())
}
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);
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)
{
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;