[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frozen fole is read in text mode but created in binary mode.

From: Eric Blake
Subject: Re: Frozen fole is read in text mode but created in binary mode.
Date: Mon, 30 Jan 2023 14:26:12 -0600
User-agent: NeoMutt/20220429

On Sat, Jan 28, 2023 at 10:31:04PM +0100, Juan Manuel Guerrero wrote:
> I do not know if this issue has already been reported, but for all
> systems that distinguish between binary and text I/O, the file should
> be read in the same mode than it has been created or it may rise reading
> issues.  When a "frozen" file is created in produce_frozen_state() this
> is done using binary mode and that is ok.  But when it later is reloaded,
> the reading is done without specifying the mode and this defaults to
> text mode breaking/aborting the reading process.  The patch below fixes
> the issue but it is only intended as suggestion.  Fix the issue as you
> like.

Thanks for the report.  I'm not sure if calling SET_BINARY() is the
best fix, or if it is better to teach m4_path_search() which files
must be opened in binary mode (vs. in default mode, where the default
mode might be text on platforms where text is distinct from binary).
I'll give it some more thought, but may end up including your patch as
written if I can't think of anything more elegant.

> +++ b/src/freeze.c
> @@ -268,6 +268,7 @@ reload_frozen_state (const char *name)
>    file = m4_path_search (name, NULL);
>    if (file == NULL)
>      m4_failure (errno, _("cannot open %s"), name);
> +  SET_BINARY (fileno (file));
>    current_file = name;
>    allocated[0] = 100;

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]