[PATCH v2] libio: Fix stream orientation when using fread [BZ #22796]
Florian Weimer
fweimer@redhat.com
Tue Mar 18 10:32:59 GMT 2025
* Samuel Zeter:
> diff --git a/libio/fileops.c b/libio/fileops.c
> index a59e248142..7921fa0fb2 100644
> --- a/libio/fileops.c
> +++ b/libio/fileops.c
> @@ -1328,6 +1328,10 @@ _IO_file_xsgetn (FILE *fp, void *data, size_t n)
>
> want = n;
>
> + /* Set the stream to byte oriented */
> + if (fp->_mode == 0)
> + _IO_fwide (fp, -1);
> +
> if (fp->_IO_buf_base == NULL)
> {
> /* Maybe we already have a push back pointer. */
Aren't there are other xsgetn methods for different stream types? Then
this change will not fix them.
I think it's better to leave orientation handling to the external
interface (so for example, __underflow (for getc_unlocked) and fread).
Thanks,
Florian
More information about the Libc-alpha
mailing list