From patchwork Sun Feb 1 20:52:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 435289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2F8FB14014D for ; Mon, 2 Feb 2015 07:53:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :cc:content-type; q=dns; s=default; b=L6XWIAJP5fogSbgkhnTc9gKg8i 3t86axyR1PSoEMGSBGwARmoLg5p0/nCe0GPbWFiOY0ODOyk50iv/B8F3/bYYVeoJ 3wUVUESkMyUGZLQMQUu+Yw5Wxx1NVI9brTv+hwVc4hAQILaoVc9t9lfoY8Lpd2cK 1ZcJZ9JBgdCZVTytI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :cc:content-type; s=default; bh=fXglBEu+BYHw720TWfnRTZZG38E=; b= cdHiNgAMWengSWy3D77Rph21KdSJ3exdOdEsSt6hxh/yEadHnM5A7okGdZoirPz7 z3Okcgmyw4CFLbIbCiBn5gr14o1C7bgVCY363KHYf6jO8YL6eBnWpuvbs+gcIyY/ +79filXjOgoDFyIShKHjSf3EfqB6TN1jYDLEfSb5IHQ= Received: (qmail 15343 invoked by alias); 1 Feb 2015 20:53:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15330 invoked by uid 89); 1 Feb 2015 20:53:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-vc0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type; bh=U4YSos/TkIemz/6awygufyHayhlqzY9mUIwCORGoYSY=; b=k3mT6joxvPGGttGFOdiqo5kMKS3gw8Uf1N79CNnqurtBT67l1ufX/flGrkeKkllW39 Mz5/2Jt33nhjK9NQC3g3j9Zl9e26msm7QMaxIZblt2VCw8OksLAZLN1oH8X4eqVobKBR cpZTewbUlwnwCSumO8NwZq8Ij0gtebeu0+OslTzQTF7NPyNFbWKW7gCWcY+DdGzVDrH5 9X85ONgMrHIu6DiYD3ZqSqSCxi+5Cit8bGIa+Sj1LwrWwbb0rl7iMdqnuNckU7G46LZW 0P6oKuBFAFnoA+JjIyTpR2K3afmx9cXjGotNbb9vRw1yvgBTkTLkuUp3oPXaVb5XJ1lr JKig== X-Gm-Message-State: ALoCoQmirtddc+vvlcjiw0h/tzNF6dpCR4yKnFVfuIGhxMas3+T08Fmo3ME84+NcDgDWrX3bn8/a X-Received: by 10.52.110.134 with SMTP id ia6mr8141224vdb.94.1422823999773; Sun, 01 Feb 2015 12:53:19 -0800 (PST) MIME-Version: 1.0 From: Paul Pluzhnikov Date: Sun, 1 Feb 2015 12:52:48 -0800 Message-ID: Subject: [patch] Fix for heap overflow in wscanf (BZ 16618) To: GLIBC Devel Cc: Joseph Myers Greetings, Attached patch is a rather obvious fix for BZ 16618. I believe this bug deserves a CVE (I've asked for one), and the fix should definitely go into 2.21. Tested on Linux/x86_64, no new failures. Thanks, --- Paul Pluzhnikov 2015-02-01 Paul Pluzhnikov [BZ #16618] * stdio-common/vfscanf.c (ADDW): Correct alloca size check and fix heap buffer overflow. diff --git a/NEWS b/NEWS index c91b9fc..85b2948 100644 --- a/NEWS +++ b/NEWS @@ -10,15 +10,16 @@ Version 2.21 * The following bugs are resolved with this release: 6652, 10672, 12674, 12847, 12926, 13862, 14132, 14138, 14171, 14498, - 15215, 15378, 15884, 16009, 16418, 16191, 16469, 16576, 16617, 16619, - 16657, 16740, 16857, 17192, 17266, 17273, 17344, 17363, 17370, 17371, - 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522, 17555, 17570, - 17571, 17572, 17573, 17574, 17582, 17583, 17584, 17585, 17589, 17594, - 17601, 17608, 17616, 17625, 17630, 17633, 17634, 17635, 17647, 17653, - 17657, 17658, 17664, 17665, 17668, 17682, 17702, 17717, 17719, 17722, - 17723, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747, 17748, - 17775, 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, 17801, - 17803, 17806, 17834, 17844, 17848, 17868, 17869, 17870, 17885, 17892. + 15215, 15378, 15884, 16009, 16418, 16191, 16469, 16576, 16617, 16618, + 16619, 16657, 16740, 16857, 17192, 17266, 17273, 17344, 17363, 17370, + 17371, 17411, 17460, 17475, 17485, 17501, 17506, 17508, 17522, 17555, + 17570, 17571, 17572, 17573, 17574, 17582, 17583, 17584, 17585, 17589, + 17594, 17601, 17608, 17616, 17625, 17630, 17633, 17634, 17635, 17647, + 17653, 17657, 17658, 17664, 17665, 17668, 17682, 17702, 17717, 17719, + 17722, 17723, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747, + 17748, 17775, 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, + 17801, 17803, 17806, 17834, 17844, 17848, 17868, 17869, 17870, 17885, + 17892. * A new semaphore algorithm has been implemented in generic C code for all machines. Previous custom assembly implementations of semaphore were diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index cd129a8..b2ad0c5 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -274,9 +274,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, CHAR_T *old = wp; \ size_t newsize = (UCHAR_MAX + 1 > 2 * wpmax \ ? UCHAR_MAX + 1 : 2 * wpmax); \ - if (use_malloc || !__libc_use_alloca (newsize)) \ + if (use_malloc || !__libc_use_alloca (newsize * sizeof (CHAR_T))) \ { \ - wp = realloc (use_malloc ? wp : NULL, newsize); \ + wp = realloc (use_malloc ? wp : NULL, newsize * sizeof (CHAR_T)); \ if (wp == NULL) \ { \ if (use_malloc) \