GNU bug report logs -
#5996
[PATCH] base64: always treat input in binary mode
Previous Next
Reported by: Eric Blake <eblake <at> redhat.com>
Date: Wed, 21 Apr 2010 14:24:02 UTC
Severity: normal
Tags: patch
Merged with 5994
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5996 in the body.
You can then email your comments to 5996 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#5996
; Package
emacs
.
(Wed, 21 Apr 2010 14:24:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eric Blake <eblake <at> redhat.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 21 Apr 2010 14:24:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Necessary for cygwin. Technically, this patch is not correct,
in that it clobbers O_APPEND, but it is no different than any
other use of xfreopen to force binary mode, so all such uses
should be fixed at once in a later patch.
* src/base64.c (main): Open input in binary mode.
* THANKS: Update.
Reported by Yutaka Amanai.
---
> base64 doesn't call freopen() nor setmode() against stdin, and doesn't
> give "rb" flag to fopen(). So, base64 sometimes fails to encode data
> correctly on some environment. For example, zsh on Cygwin forces stdin
> to be text-mode.
Thanks for the report. I'll commit this later today if there are no
objections; it should have no impact for any platform that does not
have O_BINARY, and although it is not perfect on Cygwin, it is not
too much to add to my workload for creating the cygwin port of coreutils
8.5. And someday I'll get around to creating the new gnulib interface
for gracefully enforcing binary streams without clobbering O_APPEND.
src/base64.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/base64.c b/src/base64.c
index 34569ec..41e9dea 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -29,6 +29,7 @@
#include "xstrtol.h"
#include "quote.h"
#include "quotearg.h"
+#include "xfreopen.h"
#include "base64.h"
@@ -289,10 +290,14 @@ main (int argc, char **argv)
infile = "-";
if (STREQ (infile, "-"))
- input_fh = stdin;
+ {
+ if (O_BINARY)
+ xfreopen (NULL, "rb", stdin);
+ input_fh = stdin;
+ }
else
{
- input_fh = fopen (infile, "r");
+ input_fh = fopen (infile, "rb");
if (input_fh == NULL)
error (EXIT_FAILURE, errno, "%s", infile);
}
--
1.6.6.1
bug reassigned from package 'emacs' to 'coreutils'.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Apr 2010 06:00:03 GMT)
Full text and
rfc822 format available.
Merged 5994 5996.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 22 Apr 2010 06:00:04 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#5996
; Package
coreutils
.
(Thu, 22 Apr 2010 17:01:02 GMT)
Full text and
rfc822 format available.
Message #12 received at 5996 <at> debbugs.gnu.org (full text, mbox):
Hi,
The following message got resent to bug-gnu-emacs rather than
bug-coreutils, because debbugs got confused.
We can discuss the reasons on help-debbugs if anyone is interested.
(Short answer: it looks like the mail you sent had two separate To:
headers, and a changed Subject: header with no bug number, both of
which confused debbugs. It may be possible to improve this a bit.)
Eric Blake wrote:
> Necessary for cygwin. Technically, this patch is not correct,
> in that it clobbers O_APPEND, but it is no different than any
> other use of xfreopen to force binary mode, so all such uses
> should be fixed at once in a later patch.
>
> * src/base64.c (main): Open input in binary mode.
> * THANKS: Update.
> Reported by Yutaka Amanai.
> ---
>
>> base64 doesn't call freopen() nor setmode() against stdin, and doesn't
>> give "rb" flag to fopen(). So, base64 sometimes fails to encode data
>> correctly on some environment. For example, zsh on Cygwin forces stdin
>> to be text-mode.
>
> Thanks for the report. I'll commit this later today if there are no
> objections; it should have no impact for any platform that does not
> have O_BINARY, and although it is not perfect on Cygwin, it is not
> too much to add to my workload for creating the cygwin port of coreutils
> 8.5. And someday I'll get around to creating the new gnulib interface
> for gracefully enforcing binary streams without clobbering O_APPEND.
>
> src/base64.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/base64.c b/src/base64.c
> index 34569ec..41e9dea 100644
> --- a/src/base64.c
> +++ b/src/base64.c
> @@ -29,6 +29,7 @@
> #include "xstrtol.h"
> #include "quote.h"
> #include "quotearg.h"
> +#include "xfreopen.h"
>
> #include "base64.h"
>
> @@ -289,10 +290,14 @@ main (int argc, char **argv)
> infile = "-";
>
> if (STREQ (infile, "-"))
> - input_fh = stdin;
> + {
> + if (O_BINARY)
> + xfreopen (NULL, "rb", stdin);
> + input_fh = stdin;
> + }
> else
> {
> - input_fh = fopen (infile, "r");
> + input_fh = fopen (infile, "rb");
> if (input_fh == NULL)
> error (EXIT_FAILURE, errno, "%s", infile);
> }
> --
> 1.6.6.1
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#5996
; Package
coreutils
.
(Thu, 22 Apr 2010 17:13:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 5996 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 04/22/2010 11:00 AM, Glenn Morris wrote:
>
> Hi,
>
> The following message got resent to bug-gnu-emacs rather than
> bug-coreutils, because debbugs got confused.
Well, my screw-up with To: fields means that my planned review period
was delayed...
>> Thanks for the report. I'll commit this later today if there are no
>> objections; it should have no impact for any platform that does not
>> have O_BINARY, and although it is not perfect on Cygwin, it is not
>> too much to add to my workload for creating the cygwin port of coreutils
>> 8.5. And someday I'll get around to creating the new gnulib interface
>> for gracefully enforcing binary streams without clobbering O_APPEND.
But I'd still like to commit this in time for coreutils 8.5 later today
if there are no complaints.
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Thu, 22 Apr 2010 17:53:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Eric Blake <eblake <at> redhat.com>
:
bug acknowledged by developer.
(Thu, 22 Apr 2010 17:53:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 5996-done <at> debbugs.gnu.org (full text, mbox):
Eric Blake wrote:
> On 04/22/2010 11:00 AM, Glenn Morris wrote:
>>
>> Hi,
>>
>> The following message got resent to bug-gnu-emacs rather than
>> bug-coreutils, because debbugs got confused.
>
> Well, my screw-up with To: fields means that my planned review period
> was delayed...
>
>>> Thanks for the report. I'll commit this later today if there are no
>>> objections; it should have no impact for any platform that does not
>>> have O_BINARY, and although it is not perfect on Cygwin, it is not
>>> too much to add to my workload for creating the cygwin port of coreutils
>>> 8.5. And someday I'll get around to creating the new gnulib interface
>>> for gracefully enforcing binary streams without clobbering O_APPEND.
>
> But I'd still like to commit this in time for coreutils 8.5 later today
> if there are no complaints.
That patch looks fine.
You're welcome to push it. Thanks!
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Thu, 22 Apr 2010 17:53:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Yutaka Amanai <yasai-itame1942 <at> jade.plala.or.jp>
:
bug acknowledged by developer.
(Thu, 22 Apr 2010 17:53:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 5996-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 04/22/2010 11:52 AM, Jim Meyering wrote:
>> But I'd still like to commit this in time for coreutils 8.5 later today
>> if there are no complaints.
>
> That patch looks fine.
> You're welcome to push it. Thanks!
Committed.
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 21 May 2010 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 15 years and 34 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.