From patchwork Tue Jul 18 11:48:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108118 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5809159qge; Tue, 18 Jul 2017 04:50:49 -0700 (PDT) X-Received: by 10.223.128.209 with SMTP id 75mr819522wrl.99.1500378649621; Tue, 18 Jul 2017 04:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500378649; cv=none; d=google.com; s=arc-20160816; b=frSl99sDjearCaTJXnk2rTjmAyLbMsPNHgN5WTFf4VHxC7WLQtfWni1eXkqEcY/ISS R3y+/zYOn/q1ix5L+QIdTjME+FKXgHpbiUixvW5k9xqN1X4K+sa4OB760jFVRkK1t66z 3c6+8jMSCRNXfkxdYhedTcti2SEyMPkZInvVG7gksGyFBZvX4CDOiQxDjRyhW/Y3NBvg mNsimp+hr6akiPEilU30B9DOhr/yhABZx3YWNlSBJ3pUcXkSEEkBy7IrGdVk3mnXwIBq t1nmGl3wRAhtafrfNI+kaUjGnPLqWDdamQIddzHOUd28m+DOAfJy79rlZqM1M7d9ezcK g8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=ooQd4aJ0bEeutPVhtflqMNlWT8uAwjOXj5Zc+IzUkRM=; b=eVNOTJ7JNeX6I7/qo0C0AanshQ/YOiDg8yoM2j4xWcUTCeVhHblqSp1vDiKM4UQFiS I5fIzBeEcEjp5HA9cj5FLnuZkRUnnMF6ItkLRXYytzduy29cGMKLj76jLO3onMZ9HSCm YEbMvHyYRZ32UT+nt/B3TNIpqrV5WhrvQ9qW4IRO26uWCEuieGMF8dYFmBbfKjLYGwJo QWx60EvHdbBXvOcPdsDDATf3Nz3XVIjaDNnfXPipAtjmyVPc07eg/hSxglC0IOPfv91h q786s9SP3eXf8j1jm1zVpG014V3TBC5Hijs1OCoQNOykP160+gtsR0gMoP/F6Z8Iy1Is ACUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id o2si1539280wra.335.2017.07.18.04.50.48; Tue, 18 Jul 2017 04:50:49 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4270B267196; Tue, 18 Jul 2017 13:50:47 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 44C4B267198; Tue, 18 Jul 2017 13:50:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by alsa0.perex.cz (Postfix) with ESMTP id E114C26719C for ; Tue, 18 Jul 2017 13:50:29 +0200 (CEST) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lpijq-1eAKCA2Z0Q-00fTHQ; Tue, 18 Jul 2017 13:49:24 +0200 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai , Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:07 +0200 Message-Id: <20170718114820.3681255-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170718114820.3681255-1-arnd@arndb.de> References: <20170718114820.3681255-1-arnd@arndb.de> X-Provags-ID: V03:K0:XU1UwIz9m7DWf40g5+hdOzp+VrDQrkg5UL1dBG7DL+YYVvKdRxe ZJJqdiV2oqwClkUdyVOZ5fTxrVPn47uRBJgJpQLDyT6XMdwsdKCs5KbIFrhlQjUU4WquXle 7ylcCbWl+Biynf5WkZYJReqxKuXA9L4UmHGto/HCB2rWbp4GWuoLvbq6nL64KY3SwXuIIpz WDe2pLJBxRLfo7g8fi/lA== X-UI-Out-Filterresults: notjunk:1; V01:K0:P5JoDUM3VOA=:1Tf1RkMrPlrxyvqIhcatNv XnfCD1VhquQAh/UG+8uKBpx+fYKnDXqimnWrr5HdWZ1R3JdSY0IcI+GIft+EpalstBuL1do5e 3x5/LnRggoesE/ajcDNP1LxbZDh2et9HWLIvj3/oTPYLsAO1ax9rIItWewVXR9TM8ii8BagYF shljqEJ/8kaFMav9mSI5tqLehJxxSjpfgJ9LkVbq7dEdiwq3AP5mY0SyqJFSfayx+RAzUloXs 1gYYDqUuysRoddba9WqgHAMLQJvEQQ6OErkgkRUX0EDvDMTg0+vdx14caksVvmM6ZtC4ZkmqT 6drH1WbI8oCwudwa3WJGVSglf73uiqbn/m2Z4h0f9GaNdDMBOUuG9nGjTgo91ZrQtWvsKZV+4 Z43wcXaGjUAPedVJ+zNefl+PZ07gn6Slh3gtfD/hIVTExlA+erJ1RlR6/ggzIdB21eYTLzNM0 7/+D3tWqiZvhtsDI0cXZ+P1N+rUe9G7vE+R47oWLm+RtP7mNzbC6ARzMrDkTwscZPvyMWC6BL 3iWH/RaxMVKXbrUinni3co1hfUDJ3a7Am61+0Y6kSG13O0aqp3QZtgb4OZG5erBSL/HGGV+BA KPMbNa5lsbx2nO9pFO1KpSBZpfYyiIFwhlxnOpymBF78GBMD0ufEHcrtbkn1jU1ZUT6f9zUGB oRNLVxClghMv1VH/06LH4VtM3r1JFZKZNhRwhsPFEzNUtp9glzdV/ZmCMHL2J0i5VBUZTlq7K O3RjCRm+9q270FOT3Gnj4HxO1CaF/8hYsGP5jg== Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH v2 4/7] ALSA: opti9xx: fix format string overflow warning X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org We pass a long name from "codec->pcm->name" into the longname string of the same length: sound/isa/opti9xx/miro.c: In function 'snd_miro_probe': sound/isa/opti9xx/miro.c:1356:39: error: '%s' directive writing up to 79 bytes into a region of size between 35 and 72 [-Werror=format-overflow=] sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", ^~ sound/isa/opti9xx/miro.c:1356:26: note: using the range [0, 4294967295] for directive argument sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/isa/opti9xx/miro.c:1356:2: note: 'sprintf' output between 32 and 185 bytes into a destination of size 80 sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", There is no easy way to avoid the theoretical overflow in this case, but using snprintf() will turn it into a harmless truncation. Signed-off-by: Arnd Bergmann --- sound/isa/opti9xx/miro.c | 7 ++++--- sound/isa/opti9xx/opti92x-ad1848.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) -- 2.9.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index bcbff56f060d..1c5a12fa8be3 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -1353,9 +1353,10 @@ static int snd_miro_probe(struct snd_card *card) } strcpy(card->driver, "miro"); - sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, miro->name, codec->pcm->name, - miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); + snprintf(card->longname, sizeof(card->longname), + "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", + card->shortname, miro->name, codec->pcm->name, + miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) rmidi = NULL; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index ceddb392b1e3..56dc581c57d5 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -879,13 +879,15 @@ static int snd_opti9xx_probe(struct snd_card *card) strcpy(card->driver, chip->name); sprintf(card->shortname, "OPTi %s", card->driver); #if defined(CS4231) || defined(OPTi93X) - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, codec->pcm->name, - chip->wss_base + 4, irq, dma1, xdma2); + snprintf(card->longname, sizeof(card->longname), + "%s, %s at 0x%lx, irq %d, dma %d&%d", + card->shortname, codec->pcm->name, + chip->wss_base + 4, irq, dma1, xdma2); #else - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", - card->shortname, codec->pcm->name, chip->wss_base + 4, irq, - dma1); + snprintf(card->longname, sizeof(card->longname), + "%s, %s at 0x%lx, irq %d, dma %d", + card->shortname, codec->pcm->name, chip->wss_base + 4, irq, + dma1); #endif /* CS4231 || OPTi93X */ if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)