From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14825 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 1/1] ungetc: Cast to unsigned char before push back to stream Date: Fri, 18 Oct 2019 15:15:28 +0200 Message-ID: <20191018131526.GM7832@port70.net> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="255164"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: "wangjianjian (C)" To: musl@lists.openwall.com Original-X-From: musl-return-14841-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 18 15:15:42 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iLS6Y-0014HF-7d for gllmg-musl@m.gmane.org; Fri, 18 Oct 2019 15:15:42 +0200 Original-Received: (qmail 9361 invoked by uid 550); 18 Oct 2019 13:15:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9341 invoked from network); 18 Oct 2019 13:15:39 -0000 Mail-Followup-To: musl@lists.openwall.com, "wangjianjian (C)" Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:14825 Archived-At: * wangjianjian (C) [2019-10-18 12:35:45 +0000]: > >From 4d24e6fee85ed878dc632dd29aabeb7c7454952e Mon Sep 17 00:00:00 2001 > From: Wang Jianjian > Date: Fri, 18 Oct 2019 20:28:29 +0800 > Subject: [PATCH 1/1] ungetc: Cast to unsigned char before push back to stream > > Per Posix standard, casting to unsigned char is need before returning C > and pushing C back to stream. > > Signed-off-by: Wang Jianjian > --- > src/stdio/ungetc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/stdio/ungetc.c b/src/stdio/ungetc.c > index 180673a4..9733091a 100644 > --- a/src/stdio/ungetc.c > +++ b/src/stdio/ungetc.c > @@ -12,9 +12,9 @@ int ungetc(int c, FILE *f) > return EOF; > } > > - *--f->rpos = c; > + *--f->rpos = (unsigned char)c; this is a noop since assignment will do the conversion. > f->flags &= ~F_EOF; > > FUNLOCK(f); > - return c; > + return (unsigned char)c; i think this fixes a real bug. > } > -- > 2.17.1 > > BR, > Wang Jianjian