wks: Put stdout into binary mode for Windows.

* tools/send-mail.c (send_mail_to_file): Call es_set_binary.
--

Without that, output to stdout via --send is mangled: The "\r\n" is
translated to "\r\r\n" which is bad because other
software (e.g. Thunderbird) translates this again to "\n\n" and thus
put all mail header liens after the first into the body.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-03-08 17:23:31 +01:00
parent dd60e868d2
commit 5c83759364
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 15 additions and 5 deletions

View File

@ -71,13 +71,23 @@ send_mail_to_file (estream_t fp, const char *fname)
if (!buffer)
return gpg_error_from_syserror ();
outfp = !strcmp (fname,"-")? es_stdout : es_fopen (fname, "wb");
if (!outfp)
if (!strcmp (fname,"-"))
{
err = gpg_error_from_syserror ();
log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
goto leave;
outfp = es_stdout;
es_set_binary (es_stdout);
}
else
{
outfp = es_fopen (fname, "wb");
if (!outfp)
{
err = gpg_error_from_syserror ();
log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
goto leave;
}
}
for (;;)
{
if (es_read (fp, buffer, sizeof buffer, &nbytes))