From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E7F443858D20 for ; Wed, 15 Nov 2023 16:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E7F443858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E7F443858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700065906; cv=none; b=lw60o6DI4yALeRm5x82YUA5HDnyjEmPcbSiEXuP+E7vVigmVCvGGSJQI+YmR7CmWQHG6W8u/9A1J8YdT/Al6/uZR3/Vt1ZIBf5mkHav3k4iOjoTt1Ua6II57CmrxUiuU5+8AKgmx0Xsj7vpE/+NlN+gAlSAxQufI1HFwNC8Q/zQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700065906; c=relaxed/simple; bh=63rbHk/Zw95I2qqWvqxiPCIe8nJuzc1Wy9WMpOwLAdQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=jW8JyiYaM7qeqWLUHTvkRw4mHjSbxDsJhVFV2zI/5Ko0b4cuLy2E4EMd0us0mGFC2najjsmi+C1HG6/WBwafILF0nVOJEjnFSqmz73TI4Ui6dt60HgU+d/n0Rs6mr1LEEjY9a2XEG6WbN6CWYgsPEev/Wolv7FhRFZOwI8kiln8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700065903; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=dC3gfr6Cxo4n+jO8UTGQorFjR+9b/ZWF4GCI8AWv4Ts=; b=B35xRtxK4oe39TAO7w/UogGV3eFkXkcVcU45sUqZa689myyeTyhhxaPIZVD8w+T2bwNHBp 6f95f0Leds6krADEbpzG3VYcUJ6loQFjs6NABUrwWsj+5NXo+bagVBDEQFYNv/5F/AUSOT KlRUNbwPx4Mxop/OTr9I/VZwLliJTlQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-1olmqvJGOwKeSpbSWiRZGQ-1; Wed, 15 Nov 2023 11:31:41 -0500 X-MC-Unique: 1olmqvJGOwKeSpbSWiRZGQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CD3F29ABA14; Wed, 15 Nov 2023 16:31:41 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.194.184]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4F30492BFD; Wed, 15 Nov 2023 16:31:40 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 50473A80BDB; Wed, 15 Nov 2023 17:31:39 +0100 (CET) Date: Wed, 15 Nov 2023 17:31:39 +0100 From: Corinna Vinschen To: Takashi Yano , newlib@sourceware.org Subject: Re: [PATCH v2] newlib: libc: Fix bugs in the commit 3d94e07c49b5. Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Takashi Yano , newlib@sourceware.org References: <20231110160947.1518-1-takashi.yano@nifty.ne.jp> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="L/fE2RLjBv5G1MZ3" Content-Disposition: inline X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --L/fE2RLjBv5G1MZ3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi Takashi, On Nov 13 14:07, Corinna Vinschen wrote: > On Nov 11 01:09, Takashi Yano wrote: > > diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c > > index 79914af08..5053fd6c4 100644 > > --- a/newlib/libc/stdio/ungetc.c > > +++ b/newlib/libc/stdio/ungetc.c > > @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr, > > > > _newlib_flockfile_start (fp); > > > > - if (ORIENT (fp, -1) != -1) > > - { > > - _newlib_flockfile_exit (fp); > > - return EOF; > > - } > > - > > /* After ungetc, we won't be at eof anymore */ > > fp->_flags &= ~__SEOF; > > > > @@ -213,6 +207,8 @@ int > > ungetc (int c, > > register FILE *fp) > > { > > + if (ORIENT (fp, -1) != -1) > > + return EOF; > > return _ungetc_r (_REENT, c, fp); > > } > > #endif /* !_REENT_ONLY */ > > As per the reasoning in terms of old standards, we shouldn't check or set > the orientation in ungetc at all. Given all that has been discussed, I attached a followup proposal. I hope that's ok. We may want to release 3.4.10 in the next weeks. Thanks, Corinna --L/fE2RLjBv5G1MZ3 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-newlib-libc-Fix-bugs-in-the-commit-3d94e07c49b5.patch" >From 528fcc9624a505c365cdb120e0dc0f0eee60398c Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Sat, 11 Nov 2023 01:09:47 +0900 Subject: [PATCH v3] newlib: libc: Fix bugs in the commit 3d94e07c49b5. The commit 3d94e07c49b5 has a few bugs which cause testsuite failure in libstdc++. This is due to excess orientation check in __srefill_r() and _ungetc_r(). Further, sscanf() family also calls ssvfscanf() family with fp->_file == -1. This causes undesired orientation set/check for sscanf() family. This patch fixes these problems. Also, as in GLibC, do not set orientation in ungetc, and only set, but do not check orientation in ungetwc. Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.") Reported-by: Christophe Lyon Reported-by: Joel Sherrill Co-developed-by: Corinna Vinschen Signed-off-by: Takashi Yano Signed-off-by: Corinna Vinschen --- newlib/libc/stdio/asiprintf.c | 2 ++ newlib/libc/stdio/asniprintf.c | 2 ++ newlib/libc/stdio/asnprintf.c | 2 ++ newlib/libc/stdio/asprintf.c | 2 ++ newlib/libc/stdio/getc.c | 6 ++++++ newlib/libc/stdio/refill.c | 3 --- newlib/libc/stdio/siprintf.c | 2 ++ newlib/libc/stdio/siscanf.c | 2 ++ newlib/libc/stdio/sniprintf.c | 2 ++ newlib/libc/stdio/snprintf.c | 2 ++ newlib/libc/stdio/sprintf.c | 2 ++ newlib/libc/stdio/sscanf.c | 2 ++ newlib/libc/stdio/swprintf.c | 2 ++ newlib/libc/stdio/swscanf.c | 2 ++ newlib/libc/stdio/ungetc.c | 6 ------ newlib/libc/stdio/ungetwc.c | 1 + newlib/libc/stdio/vasiprintf.c | 1 + newlib/libc/stdio/vasniprintf.c | 1 + newlib/libc/stdio/vasnprintf.c | 1 + newlib/libc/stdio/vasprintf.c | 1 + newlib/libc/stdio/vsiprintf.c | 1 + newlib/libc/stdio/vsiscanf.c | 1 + newlib/libc/stdio/vsniprintf.c | 1 + newlib/libc/stdio/vsnprintf.c | 1 + newlib/libc/stdio/vsprintf.c | 1 + newlib/libc/stdio/vsscanf.c | 1 + newlib/libc/stdio/vswprintf.c | 1 + 27 files changed, 42 insertions(+), 9 deletions(-) diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index af25e9a57acd..dedb7fbfabce 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -35,6 +35,7 @@ _asiprintf_r (struct _reent *ptr, /* mark a zero-length reallocatable buffer */ f._flags = __SWR | __SSTR | __SMBF; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ @@ -61,6 +62,7 @@ asiprintf (char **strp, /* mark a zero-length reallocatable buffer */ f._flags = __SWR | __SSTR | __SMBF; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprintf.c index 97e77748e75d..e930c8d69f64 100644 --- a/newlib/libc/stdio/asniprintf.c +++ b/newlib/libc/stdio/asniprintf.c @@ -36,6 +36,7 @@ _asniprintf_r (struct _reent *ptr, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t @@ -82,6 +83,7 @@ asniprintf (char *buf, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index f82556143e74..4c9ad586020a 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -36,6 +36,7 @@ _asnprintf_r (struct _reent *__restrict ptr, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t @@ -88,6 +89,7 @@ asnprintf (char *__restrict buf, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 542e70e4c308..511d0e0f3f4a 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -35,6 +35,7 @@ _asprintf_r (struct _reent *ptr, /* mark a zero-length reallocatable buffer */ f._flags = __SWR | __SSTR | __SMBF; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ @@ -67,6 +68,7 @@ asprintf (char **__restrict strp, /* mark a zero-length reallocatable buffer */ f._flags = __SWR | __SSTR | __SMBF; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index c8781320e603..12bffaf8f79a 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -81,6 +81,9 @@ _getc_r (struct _reent *ptr, { int result; CHECK_INIT (ptr, fp); + if (ORIENT (fp, -1) != -1) + return EOF; + _newlib_flockfile_start (fp); result = __sgetc_r (ptr, fp); _newlib_flockfile_end (fp); @@ -96,6 +99,9 @@ getc (register FILE *fp) struct _reent *reent = _REENT; CHECK_INIT (reent, fp); + if (ORIENT (fp, -1) != -1) + return EOF; + _newlib_flockfile_start (fp); result = __sgetc_r (reent, fp); _newlib_flockfile_end (fp); diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index c1ef7e120b71..cd71ed1529ba 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -43,9 +43,6 @@ __srefill_r (struct _reent * ptr, CHECK_INIT (ptr, fp); - if (ORIENT (fp, -1) != -1) - return EOF; - fp->_r = 0; /* largely a convenience for callers */ /* SysV does not make this test; take it out for compatibility */ diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index bd29edd88110..b337925979bb 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -108,6 +108,7 @@ _siprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ @@ -129,6 +130,7 @@ siprintf (char *str, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c index b88b81088818..4c1363d0a766 100644 --- a/newlib/libc/stdio/siscanf.c +++ b/newlib/libc/stdio/siscanf.c @@ -90,6 +90,7 @@ siscanf (const char *str, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; @@ -114,6 +115,7 @@ _siscanf_r (struct _reent *ptr, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.c index b05ffcb12da9..852713f1ffb8 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -42,6 +42,7 @@ _sniprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ @@ -73,6 +74,7 @@ sniprintf (char *str, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 4a3084beacb3..b6130b998393 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -41,6 +41,7 @@ _snprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ @@ -78,6 +79,7 @@ snprintf (char *__restrict str, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index be66ec6f5d73..92cae46189df 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -584,6 +584,7 @@ _sprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ @@ -611,6 +612,7 @@ sprintf (char *__restrict str, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 9c50361bc026..52145fc46c20 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -429,6 +429,7 @@ sscanf (const char *__restrict str, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; @@ -459,6 +460,7 @@ _sscanf_r (struct _reent *ptr, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; diff --git a/newlib/libc/stdio/swprintf.c b/newlib/libc/stdio/swprintf.c index 634b22beb909..e590b522ced8 100644 --- a/newlib/libc/stdio/swprintf.c +++ b/newlib/libc/stdio/swprintf.c @@ -568,6 +568,7 @@ _swprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file = -1; /* No file. */ @@ -608,6 +609,7 @@ swprintf (wchar_t *__restrict str, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/swscanf.c b/newlib/libc/stdio/swscanf.c index 578ac3c93f76..0ef4d0ebde18 100644 --- a/newlib/libc/stdio/swscanf.c +++ b/newlib/libc/stdio/swscanf.c @@ -422,6 +422,7 @@ swscanf (const wchar_t *__restrict str, const wchar_t *__restrict fmt, ...) FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = wcslen (str) * sizeof (wchar_t); f._read = __seofread; @@ -446,6 +447,7 @@ _swscanf_r (struct _reent *ptr, const wchar_t *str, const wchar_t *fmt, ...) FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = wcslen (str) * sizeof (wchar_t); f._read = __seofread; diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index 79914af0806e..8b10c8218616 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr, _newlib_flockfile_start (fp); - if (ORIENT (fp, -1) != -1) - { - _newlib_flockfile_exit (fp); - return EOF; - } - /* After ungetc, we won't be at eof anymore */ fp->_flags &= ~__SEOF; diff --git a/newlib/libc/stdio/ungetwc.c b/newlib/libc/stdio/ungetwc.c index 18636d773edd..1d65a1ef039a 100644 --- a/newlib/libc/stdio/ungetwc.c +++ b/newlib/libc/stdio/ungetwc.c @@ -112,5 +112,6 @@ ungetwc (wint_t wc, struct _reent *reent = _REENT; CHECK_INIT (reent, fp); + ORIENT (fp, 1); return _ungetwc_r (reent, wc, fp); } diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index 1deb2dbcf3d8..d9c11eaf503f 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -50,6 +50,7 @@ _vasiprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR | __SMBF ; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasniprintf.c index b24cd96fb625..c85ca06e8c1a 100644 --- a/newlib/libc/stdio/vasniprintf.c +++ b/newlib/libc/stdio/vasniprintf.c @@ -36,6 +36,7 @@ _vasniprintf_r (struct _reent *ptr, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index b3787ec7a1fa..02f55caa9a95 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -36,6 +36,7 @@ _vasnprintf_r (struct _reent *ptr, len = 0; buf = NULL; } + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) buf; /* For now, inherit the 32-bit signed limit of FILE._bf._size. FIXME - it would be nice to rewrite sys/reent.h to support size_t diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index d7ec9c8400ef..b466936bd94b 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -56,6 +56,7 @@ _vasprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR | __SMBF ; + f._flags2 = 0; f._bf._base = f._p = NULL; f._bf._size = f._w = 0; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c index 8128cb772684..af07ad85e8cd 100644 --- a/newlib/libc/stdio/vsiprintf.c +++ b/newlib/libc/stdio/vsiprintf.c @@ -50,6 +50,7 @@ _vsiprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vsiscanf.c b/newlib/libc/stdio/vsiscanf.c index d7135ef71278..4e28d1079390 100644 --- a/newlib/libc/stdio/vsiscanf.c +++ b/newlib/libc/stdio/vsiscanf.c @@ -49,6 +49,7 @@ _vsiscanf_r (struct _reent *ptr, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c index e7625ffd5345..a50a0a993115 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -58,6 +58,7 @@ _vsniprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index ecf82eaefff7..d9c72b526ba5 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -64,6 +64,7 @@ _vsnprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index 4d51fd0dc03f..4d4619fd0324 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -56,6 +56,7 @@ _vsprintf_r (struct _reent *ptr, FILE f; f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; f._file = -1; /* No file. */ diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index e9e84088f7cf..6150f541bb24 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -55,6 +55,7 @@ _vsscanf_r (struct _reent *ptr, FILE f; f._flags = __SRD | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = __seofread; diff --git a/newlib/libc/stdio/vswprintf.c b/newlib/libc/stdio/vswprintf.c index 08a8545baef8..ab2e52ff4921 100644 --- a/newlib/libc/stdio/vswprintf.c +++ b/newlib/libc/stdio/vswprintf.c @@ -46,6 +46,7 @@ _vswprintf_r (struct _reent *ptr, return EOF; } f._flags = __SWR | __SSTR; + f._flags2 = 0; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? (size - 1) * sizeof (wchar_t) : 0); f._file = -1; /* No file. */ -- 2.41.0 :q --L/fE2RLjBv5G1MZ3--