From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14823 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "wangjianjian (C)" Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 1/1] ungetc: Cast to unsigned char before push back to stream Date: Fri, 18 Oct 2019 12:35:45 +0000 Message-ID: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="96052"; mail-complaints-to="usenet@blaine.gmane.org" Cc: "wangjianjian (C)" To: "musl@lists.openwall.com" Original-X-From: musl-return-14839-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 18 14:39:30 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 1iLRXV-000OsS-BZ for gllmg-musl@m.gmane.org; Fri, 18 Oct 2019 14:39:29 +0200 Original-Received: (qmail 24338 invoked by uid 550); 18 Oct 2019 12:39:26 -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 23843 invoked from network); 18 Oct 2019 12:36:16 -0000 Thread-Topic: [PATCH 1/1] ungetc: Cast to unsigned char before push back to stream Thread-Index: AdWFsFg3Uv02nVzSTRWQGEXaxYK45g== Accept-Language: en-US Content-Language: zh-CN x-originating-ip: [10.111.171.229] X-CFilter-Loop: Reflected Xref: news.gmane.org gmane.linux.lib.musl.general:14823 Archived-At: >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 stre= am 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 =3D c; + *--f->rpos =3D (unsigned char)c; f->flags &=3D ~F_EOF; FUNLOCK(f); - return c; + return (unsigned char)c; } -- 2.17.1 BR, Wang Jianjian