public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] locale: Fix signed char bug in lr_getc
Date: Tue,  5 Jul 2022 07:29:36 +0000 (GMT)	[thread overview]
Message-ID: <20220705072936.B9F60385C311@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=19d494445981a09503e4a0175732745c39dd7c21

commit 19d494445981a09503e4a0175732745c39dd7c21
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jul 5 09:05:22 2022 +0200

    locale: Fix signed char bug in lr_getc
    
    The array lr->buf contains characters, which can be signed.  A 0xff
    byte in the input could be incorrectly reported as EOF.  More
    importantly, get_string in linereader.c converts a signed input byte
    to a Unicode code point using ADDWC ((uint32_t) ch), under the
    assumption that this decodes the ISO-8859-1 input encoding.  If char
    is signed, this does not give the correct result.  This means that
    ISO-8859-1 input files for localedef are not actually supported,
    contrary to the comment in get_string.  This is a happy accident because
    we can therefore change the file encoding to UTF-8 without impacting
    backwards compatibility.
    
    While at it, remove the \32 check for MS-DOS end-of-file character (^Z).
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    Tested-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 locale/programs/linereader.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/locale/programs/linereader.h b/locale/programs/linereader.h
index 0fb10ec833..653a71d2d1 100644
--- a/locale/programs/linereader.h
+++ b/locale/programs/linereader.h
@@ -134,7 +134,7 @@ lr_getc (struct linereader *lr)
 	return EOF;
     }
 
-  return lr->buf[lr->idx] == '\32' ? EOF : lr->buf[lr->idx++];
+  return lr->buf[lr->idx++] & 0xff;
 }


                 reply	other threads:[~2022-07-05  7:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220705072936.B9F60385C311@sourceware.org \
    --to=fw@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).