From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106851 invoked by alias); 3 Jun 2019 08:40:37 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 106835 invoked by uid 9078); 3 Jun 2019 08:40:37 -0000 Date: Mon, 03 Jun 2019 08:40:00 -0000 Message-ID: <20190603084037.106834.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Fix vfwscanf(3) assignment suppression flag handling bug X-Act-Checkin: newlib-cygwin X-Git-Author: =?utf-8?q?Lucio_Andr=C3=A9s_Illanes_Albornoz?= X-Git-Refname: refs/heads/master X-Git-Oldrev: ee7e49e19388fd0f19ca1c4773d3efc5fa123d58 X-Git-Newrev: d5daede26c651f4e9d6c7abbd2dd2937a1e24e2d X-SW-Source: 2019-q2/txt/msg00018.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d5daede26c651f4e9d6c7abbd2dd2937a1e24e2d commit d5daede26c651f4e9d6c7abbd2dd2937a1e24e2d Author: Lucio Andrés Illanes Albornoz Date: Sat Jun 1 10:33:19 2019 +0200 Fix vfwscanf(3) assignment suppression flag handling bug newlib's vfwscanf(3) (or specifically, __SVFWSCANF_R()) fails to correctly set the assignment-suppressing character (`*') flag[1] which, when present in the formatting string, results in undefined behaviour comprising retrieving and dereferencing a pointer that was not supplied by the caller as such or at all. When compared to the vfscanf(3) implementation, this would appear to be over the missing goto match_failure statement preceded by the flags test seen below. Hence, this patch (re)introduces it. [1] -- Diff: --- newlib/libc/stdio/vfwscanf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index 0464b08..ffb6cc8 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -602,6 +602,7 @@ __SVFWSCANF_R (struct _reent *rptr, case L'*': if ((flags & (CHAR | SHORT | LONG | LONGDBL | SUPPRESS | MALLOC)) || width) + goto match_failure; flags |= SUPPRESS; goto again; case L'l':