From patchwork Tue Jul 18 11:48:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108116 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5808027qge; Tue, 18 Jul 2017 04:49:41 -0700 (PDT) X-Received: by 10.28.48.68 with SMTP id w65mr1878693wmw.54.1500378581769; Tue, 18 Jul 2017 04:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500378581; cv=none; d=google.com; s=arc-20160816; b=Ypo9zP/ajN/ioVvEySp14XduLyRGokSjAnXJaawplIxDwrcm5Y0BShEJ4FYyMHM0Bb A00VynSBMSx5QdaFK7mJj1Xiha/ZZrWaSdYKVzSTT0699q3xWMxoMyVRHy773KiyZ7l/ bAE2y/v3vFJvAclyVqZ1A1eEDpz0lwwSr3vnsCenGlQhKJ6JyjFTNIeowc9qv0KpD2NS /b4zLLKzunH7U4xjRqu8ssCnVzBK5JmPMKnCyJ+/mlKxiPPbiZ6gNL3abUOyNi2V7w6C eCRBGMDB/FxFkGsfbtvwNV3uwXNs21OoZbahoG7z84KiW3q4lWLMhF5yRnmv3iyoxEqK S+YA== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=OSC/DkAwk2dO53n6xahxCXvio+vVk0C1Uhsg7hUiUTw=; b=KmqhvzSSWmDEYz5WCw1IPO4L/mIUoJdmPTva82haYVpl76qMiLC829pPOKS6XENAVv PTnY6sjoZ8oZsFK14ZCT5RWXcOKr2skEkhWfrs0g25Vdvd4ebTBzImC/Cx4bFfSdg2uo RLJfn7edE6ggX3lPo2pTnua2ncSQjMjqjjQqJDgwzO+8qqDVPHFZrM+ylwpdGgmT+FNh MjMK19SjSfgvropwBQhSmxkguyOP2WMVrsSEJN7/cyPr8edgidwAx9Aw+GhO+Q6J183i eJGWod1N977PPQY2leI0BxyavX1eOeVR/EI0TSJGPhMI62zmaYR3R/SAb5hRJs1TZpE0 wQVw== 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 m63si2218856wme.38.2017.07.18.04.49.41; Tue, 18 Jul 2017 04:49:41 -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 8CF692671AB; Tue, 18 Jul 2017 13:49:35 +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 0C71F26719A; Tue, 18 Jul 2017 13:49:34 +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.8 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by alsa0.perex.cz (Postfix) with ESMTP id 100EE2664EB for ; Tue, 18 Jul 2017 13:49:28 +0200 (CEST) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0LjO9b-1e3TU93rO3-00dXLR; Tue, 18 Jul 2017 13:48:23 +0200 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Tue, 18 Jul 2017 13:48:04 +0200 Message-Id: <20170718114820.3681255-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:MFHEmLSbxWwu0LfD66O2NApKllsMEqDM9v15nYMLWr0laEPxOYq pWco4f3oAugNeMKAJ7ePlHRsqNFdShJWlPm1VLhsLWAISDTeaRI4+fvuHNn8FOFPA9PuPQt mdTTAIcI9cYmsctGHwqoXAQCwdohX0D4U2/3ZJP7B2I7BZiLJnw9bGTyK20LC/26eyOZQeB sFSqKWrnSLXkN+44fxLpg== X-UI-Out-Filterresults: notjunk:1; V01:K0:FU/DEHfgtZs=:N6NtaEuNkg7bb9lB6TtRhA 69qpxl2tZ4/93FXItb7OGNdsttq+rESU8buvc26tvP3tC+bcuYrYUFZKTFJwKOlyPOwfyV0NM HhJee42OFXJctfr5oKel6tWlSBoS94iTNPvcLk4rmUDEJV6rr/y0OHxNil3gmUP+sY4wOMtjw vI1r9d8jEU7BfHMtlUUkVMUTK8WDA+4ytJz765NFVus3GrcqnXJ68dxPGhukiaK5DViIZsS7C sXNWRe1O+xqcT6MFzHdWJ1wY7oGap3Cn+VAt6CvPiIutc7E72LaVSYDY8O/S/qSX6yGPMqkR9 Ai80sL26Ths07pJzRYGxDosAH6/WnQDi2nYB7t3nOJ34FYc4Vo/Glt6Uhldokxl0M974OPil/ ZTLb/vSYk+cUJJ5dy0bfWQ5ScPgpba8l38XpMWJnWYTohhxfe4n7xmwH/Wj1SexFo0CPEiobH Id3sNq2iyzlfwcEjCLZj+2jpYiHjmXqfJJkWoSbjr8KXvzyURMlOUIHL25386p88z8yKA1fQ+ DVCpTEPn2TDBf/i098G4zSgvQoXA0JsJIXMf1kFJ2BmzAsDnfw7YL+utQsrPXotMe66etgQB2 YNNKRILJc+d4IgQjoy45KiI2WKbJh+fR/bWs5sAM664YZZVOFxGZ1+j4nsZCLaLxMqxQozfce igW3zv45zGnHE0hEO2JRfhXPuTMt/nNX9gjZEgiNAbJnct43q4od3rZ4V3Xw4Fypdulpu8MHp 25+a8tc6n7YfrI+Br7HEK3dPvTcnE1st0jhTyQ== Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [alsa-devel] [PATCH v2 1/7] ALSA: als100: 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 The compiler sees that the format string might overflow for the longname: sound/isa/als100.c: In function 'snd_als100_pnp_detect': sound/isa/als100.c:225:27: error: ', dma ' directive writing 6 bytes into a region of size between 0 and 64 [-Werror=format-overflow=] sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/isa/als100.c:225:3: note: 'sprintf' output between 24 and 113 bytes into a destination of size 80 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", Open-coding "shortname" here gets us below the limit, and using snprintf() is a good idea too. Signed-off-by: Arnd Bergmann --- sound/isa/als100.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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/als100.c b/sound/isa/als100.c index bc9ea306ee02..6a2c5b48f3ae 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -222,15 +222,16 @@ static int snd_card_als100_probe(int dev, if (pid->driver_data == SB_HW_DT019X) { strcpy(card->driver, "DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X"); - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", - card->shortname, chip->name, chip->port, - irq[dev], dma8[dev]); + snprintf(card->longname, sizeof(card->longname), + "Diamond Tech. DT-019X, %s at 0x%lx, irq %d, dma %d", + chip->name, chip->port, irq[dev], dma8[dev]); } else { strcpy(card->driver, "ALS100"); strcpy(card->shortname, "Avance Logic ALS100"); - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, chip->name, chip->port, - irq[dev], dma8[dev], dma16[dev]); + snprintf(card->longname, sizeof(card->longname), + "Avance Logic ALS100, %s at 0x%lx, irq %d, dma %d&%d", + chip->name, chip->port, irq[dev], dma8[dev], + dma16[dev]); } if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) { From patchwork Tue Jul 18 11:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108114 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5807203qge; Tue, 18 Jul 2017 04:48:53 -0700 (PDT) X-Received: by 10.28.94.201 with SMTP id s192mr1531610wmb.100.1500378533643; Tue, 18 Jul 2017 04:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500378533; cv=none; d=google.com; s=arc-20160816; b=uHMjGaGSwBLyhnUw5p1QFwDsLoojYUH+XiCeebp9bb+fB79SEcZQinb1RbVpM2lq0M EFZD8KpfRRfj9Kho2w30Dc9AXRcx8dCYq0TZEsT50adSOiTVm9P+iAVQXmjv5Ep1yqae rTmi3fbTtf3SgGIljEU8csK6SN5cn1tIF/rcf2jeRCU4rm75EQlzEhl0u91m2KCXFYBJ DcSGNUOpP0tIRBh0M9BPaggkuYplIYxc7yIE9hWmEOvX1YGDIP2QELili7VFThdb3BFA +bLj750RaMJPwRESngk4gFE7wy1HPvrhn+T/0wFZBsOPocv63IZGd7Mb40X8gAeT73LV 8eTQ== 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=MQ7RXxlXfTQ7jL0uzod7kfWatxJ4uP4geGiDHKrcQgU=; b=flaX/S927ErDfL//n+UA167fLSVRpUjc5pQDBUdXkrpE8onRIACEk4ksZ1n4unFUIh xAOsK6gJafo07lB6gKAfkKQGhT9HAAjYFpfvdr6fLWuiD/AqrpR+fzfeA4qnlV3bGbX2 k44EE3zF4bwXVLJ2QTWHFX6MGB4OjUhGLh0d7NhrXk3Od0fx9LEt9aOmawJcjRBTFGPM MNxqpHcZrqn4sDHFlyOOVrY7C/C0GKBO7eToJvVRS+KS8TVJGknz6Qr5S6z4WAxaGk9q HAzb0ijzpx/PAW5mxiCYf7jweSbHTHG7ZfjPvzWNcNPMT9GS6/ANdCVe1KrpzCe2UJ+1 b6Iw== 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 g10si1576397wrc.359.2017.07.18.04.48.53; Tue, 18 Jul 2017 04:48:53 -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 C723C267121; Tue, 18 Jul 2017 13:48:51 +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 33D8A267176; Tue, 18 Jul 2017 13:48:51 +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.134]) by alsa0.perex.cz (Postfix) with ESMTP id 6F9FB2664EB for ; Tue, 18 Jul 2017 13:48:49 +0200 (CEST) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0M9tYC-1dMPRb3cAy-00B7P8; Tue, 18 Jul 2017 13:48:43 +0200 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Tue, 18 Jul 2017 13:48:05 +0200 Message-Id: <20170718114820.3681255-2-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:R5homueT0h4VvUv3QB93gLIODbEMuAoZ6esebcSjhcjdAyz/4ez HLczXqhM62Wx30L6TpY7RbI9ywGaO98cGLs/nQhOsS5AQQMHxBruSxYHiTlzd72zl/G0y42 9i9+Vl09UEGmdx+tyvJipyS60H9j1RVE9v5Brc/KWyeU/VurThnNIbSl4CoZvGrPCqT2Zc4 86NtOt9D496CAnuRigMCA== X-UI-Out-Filterresults: notjunk:1; V01:K0:3GDTuhKk+0w=:IOxYeHnIf51F7qPsaAZEA/ BRv9ZDO8B6Hzw1Zp5xHkIJL1Z/9GrupKx/R501Rll7BE7yFULpYwq6lGuuEP5uWwXKkVCDiEg 1svMB5FphXgNtw9tut360zX/ryF9iUvSZ0h33ahRhbGoxeueps+XF5HNjffNhFqnWZYE5u+00 iA4Ik/RZ9AhkRGTqqusgYMcfKqP2VSfyWEmMM59U5oCkZVkLjU+7uuKt2xGHDhXsXUUgAKggU mvsk8/Vxzfb34/nGxfOQU1QWeNocu09dkg/rD6/Te7Kcg5ftjzuOaG9i+OCqT07MFYKjziENB cTpT01phryr4grBYEijrBAVyimdUNIvQjRlsUcTZcqw2l1RY0cELtZq2A2WxGTCMR+PJh8Q1o MQO/8hYBaXRAkpqSrXdOglhHOynW9PCZ9iBX70sRCjluk2qTB50i8zScoZTC8ZBXHux+03p2L gVgMPvZhiAsrF5UyGyO4Op80ckGcVF+2PtgKBQUnjPkM4MnK76szjeR8CSnsSf8hggvP4vu1i kqCb72GXZAMlRE6VC2++AbxSpl6eOaNWyIPeiHi6CbCmOotW69I+Pv0t7HLfgcLe94F58dBeQ SBo4j48IFVXkF9vtPzsdHI2ZZzT9TaIg3f5yDszkbcDrpnYC9GuIwmvs8dzlUuWvNvK8QE3Wx RFhsKvY6s0mSqViO1AwB0KWqetRAyZBWTsA/3/4zYSgOztLuEW/OpJ/X9sYfYokAVBalVYeUP MRGTs/8MSPVYyBcxqWdKZnwnGmGVhKIuV2xgyw== Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [alsa-devel] [PATCH v2 2/7] ALSA: cs423x: 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 The snd_pcm name may overflow the card->longname total size: sound/isa/cs423x/cs4231.c: In function 'snd_cs4231_probe': sound/isa/cs423x/cs4231.c:115:26: error: ' at 0x' directive writing 6 bytes into a region of size between 1 and 80 [-Werror=format-overflow=] 0x%lx, irq %d, dma %d", sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes the driver to use snprintf() so we truncate the string instead of overflowing into the next field if that happens. I decided to split out the second format string for the extra DMA channel to keep the code simpler. Signed-off-by: Arnd Bergmann --- sound/isa/cs423x/cs4231.c | 18 +++++++++++------- sound/isa/cs423x/cs4236.c | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 16 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/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index e8edd9017a2f..d90ab9558f7f 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -109,13 +109,17 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n) if (error < 0) goto out; - strcpy(card->driver, "CS4231"); - strcpy(card->shortname, chip->pcm->name); - - sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - chip->pcm->name, chip->port, irq[n], dma1[n]); - if (dma2[n] >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); + strlcpy(card->driver, "CS4231", sizeof(card->driver)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); + + if (dma2[n] < 0) + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d", + chip->pcm->name, chip->port, irq[n], dma1[n]); + else + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d&%d", + chip->pcm->name, chip->port, irq[n], dma1[n], dma2[n]); error = snd_wss_mixer(chip); if (error < 0) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 1f9a3b2be7a1..4c09756c7353 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -419,15 +419,17 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) if (err < 0) return err; } - strcpy(card->driver, chip->pcm->name); - strcpy(card->shortname, chip->pcm->name); - sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", - chip->pcm->name, - chip->port, - irq[dev], - dma1[dev]); - if (dma2[dev] >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); + strlcpy(card->driver, chip->pcm->name, sizeof(card->driver)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); + if (dma2[dev] < 0) + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %i, dma %i", + chip->pcm->name, chip->port, irq[dev], dma1[dev]); + else + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %i, dma %i&%d", + chip->pcm->name, chip->port, irq[dev], dma1[dev], + dma2[dev]); err = snd_wss_timer(chip, 0); if (err < 0) 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) From patchwork Tue Jul 18 11:48:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108117 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5808430qge; Tue, 18 Jul 2017 04:50:05 -0700 (PDT) X-Received: by 10.223.183.12 with SMTP id l12mr947096wre.103.1500378605257; Tue, 18 Jul 2017 04:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500378605; cv=none; d=google.com; s=arc-20160816; b=XYSjKoDBQM9O858daVYX8UI/mfkfnOfWx4O0X84fYaFIZX0ylsu9m7Wl7Yl5xSWu+F rJG3VmF/zhnGVErpnhdu5SeXIGSiQsHLuKu/Gb0ptoOOXoGn7JtRlUaS960PDtN4x7x3 t0E2gQmKpJlGhsOdSZVAXMysegu5L9qNoQ91aIIPkB+U53Loh315gVIlfQRZZ54uHnTX m3KA308BYTTe8u3flAUrgdEDlw++agSny4MHyrEsMQus7yCzJFteRBQndDvVwCMgMAFO y2Eaf3woRVRxNe4TSp1rZ3FLRjszPallR6DxhpCPMrTh2i884aHAaIl5IqyArhtCbWqX 7cAg== 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=+rklk7C6ziil8BdMS+eKtexYj3NI9t1DFqRBbKTaxqk=; b=hikLHMgItTpGj6r1tZbrOUH+A24+WUTG3vVrp8ocHUCQKTRHY9qhDFGDT5qeneJfm3 dBiykempKS/jiibRFrzcUiTNO6eTfMDlkP1pKMYdUPvWdRx8JE9FLcum8Yot3l9mne2Y 3AoXmflABGYj9MrRJVT8Wx/zwLoFivJWU5klRh1k6/2vzV9O1dnQTObc8ZQLgj9Z1bZA LQPH7mBqMsIl2vwEbBaU/eEHEp39pA4jxon2DXppM6nAZ0L78sLm1hsZlqoBFCIA41Ti XtSQ4m+l/si5Vs73QYr3RRBcFcOJ78mSvA8lOUfWzH35br8mSlaJVgT9ZzPTzbw26cSP z8NQ== 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 201si12750171wmr.133.2017.07.18.04.50.04; Tue, 18 Jul 2017 04:50:05 -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 270CD2671D3; Tue, 18 Jul 2017 13:50:03 +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 41A452671C5; Tue, 18 Jul 2017 13:50:02 +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.134]) by alsa0.perex.cz (Postfix) with ESMTP id 1D01E2671D1 for ; Tue, 18 Jul 2017 13:49:51 +0200 (CEST) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0LhifF-1e1lcY09AX-00mw3X; Tue, 18 Jul 2017 13:49:47 +0200 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Tue, 18 Jul 2017 13:48:08 +0200 Message-Id: <20170718114820.3681255-5-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:7nQveC8MF12Xa2oqisESjTktCk0Nd74SDWRvnz2I/DFPMbPoWK0 Q2MD/VhowjQJz3Rp6Jq2wO3rYGq7S/JtLQdAvq2e6XzSFFU9+fuQs4RY1qeNAvISagkr0vQ Nw0Yf+6hoatzJsIolhyOFAQd+Iy0+RiBjaBMUK4UsCmdHsO9sK/s6YAgTz7HND7AJnHYsTS H/HYrd7A+2sAhq8CRGw5A== X-UI-Out-Filterresults: notjunk:1; V01:K0:ehOB65Ro9IU=:pfMyHJLEMAC94oJGzZsZkv QTCrLDk36aGCZKNrilrBf7Sn/zhO5I54YeBA2dNIcZrsp48fqwgWCyDwLrefJgcnl20BDNTwe KVEOiuFMk4rCXJ7i6BERZHhtwD7F/Ooh+gjqHNZTVIXJ6sPKVLFeEWbezp2KFu8iLd4ndmHG5 mh31cdIXQPzODQFHsdhw9sr2hTb0JMaPcszhDcXzeqyED4CcHnbBzM1t4W/3YVUlq2Sg2G1Vo slgSCqsNjIq8Bfl4ZBGPz5psDRaFOSsqnlhbjL9udnxIVaU4AE4zmB3PXRUJiSNWnk5jg9yz6 wnlFiWsP+/Z3fShzeSJgGa1TOIc4+aogv24w09QLskBfySF6pAC26buF31pEVMyJK3l9ycrQ+ fRDVGz9a3KKciRay+VhRFLAUOJIoNTpMIJS55A2PwRU6RL6zRp464pgX7BQ2IN8DSIxy8LDcy SMR6im/pjJTp+gjT/+K/w70GCSNVaqNIYtTjfo4RKlAv4U/nO4tYXIugplvwf9SI/Xi4PUYcF 49P9hoR6cjrEV+C/q05nm3ILl2pUhAnftFxqAQSaIlR7h9zRpbjDJpxwbzuobLXI4Nbxa0yE/ ELczy/h8iGctOAnY24n61MYCdzQ/Gxpl/Cs4dNwYn/fJR4R5jPEcyGtGKp5qWlbxYbPIrPyb0 jf8XnB69sYJv0oI5HQYCLIPGjUGnJBKoXnQCQxGlfKPANI86Z6NtpXqmKUVZ0cUWmbkyNW24E tBNLjqjrfJvlAg0nJJ1+HhDnboINY8V4EHPPJQ== Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [alsa-devel] [PATCH v2 5/7] ALSA: mixart: fix 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 Using a temporary string produces warnings about a possible overflow in sprintf: sound/pci/mixart/mixart.c: In function 'snd_mixart_probe': sound/pci/mixart/mixart.c:1353:28: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); ^~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1353:28: note: using the range [-2147483648, 2147483647] for directive argument sound/pci/mixart/mixart.c:1353:3: note: 'sprintf' output between 10 and 51 bytes into a destination of size 32 sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1354:27: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 80 [-Werror=format-overflow=] sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); ^~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1354:27: note: using the range [-2147483648, 2147483647] for directive argument sound/pci/mixart/mixart.c:1354:3: note: 'sprintf' output between 10 and 99 bytes into a destination of size 80 Skipping the intermediate, we can get gcc to see that it is in fact safe here. Signed-off-by: Arnd Bergmann --- sound/pci/mixart/mixart.c | 10 +++++----- sound/pci/mixart/mixart.h | 4 ---- 2 files changed, 5 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/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 80d439944cb5..6d7fbf30618b 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1313,9 +1313,6 @@ static int snd_mixart_probe(struct pci_dev *pci, } mgr->irq = pci->irq; - sprintf(mgr->shortname, "Digigram miXart"); - sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, irq %i", mgr->shortname, mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq); - /* init mailbox */ mgr->msg_fifo_readptr = 0; mgr->msg_fifo_writeptr = 0; @@ -1350,8 +1347,11 @@ static int snd_mixart_probe(struct pci_dev *pci, } strcpy(card->driver, CARD_NAME); - sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); - sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); + snprintf(card->shortname, sizeof(card->shortname), + "Digigram miXart [PCM #%d]", i); + snprintf(card->longname, sizeof(card->longname), + "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", + mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); if ((err = snd_mixart_create(mgr, card, i)) < 0) { snd_card_free(card); diff --git a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h index 426743871540..69b3ece099ad 100644 --- a/sound/pci/mixart/mixart.h +++ b/sound/pci/mixart/mixart.h @@ -74,10 +74,6 @@ struct mixart_mgr { /* memory-maps */ struct mem_area mem[2]; - /* share the name */ - char shortname[32]; /* short name of this soundcard */ - char longname[80]; /* name of this soundcard */ - /* one and only blocking message or notification may be pending */ u32 pending_event; wait_queue_head_t msg_sleep; From patchwork Tue Jul 18 11:48:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108119 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5809676qge; Tue, 18 Jul 2017 04:51:21 -0700 (PDT) X-Received: by 10.28.46.3 with SMTP id u3mr1918251wmu.68.1500378681538; Tue, 18 Jul 2017 04:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500378681; cv=none; d=google.com; s=arc-20160816; b=mVIEgtBD4v+Nvgh0jZliKFow8nWcFsoBZ4/GEYSWYLsch+aX99w2FTUbdXcq1RrmbX 2vWX/M/7gvs0dPlZhCzossM4AFM1UASc3xGDV8PR0VeMD6KY6LQRsY/Bl7o39g7LnCfD 7Oa9lOD+e4UU47VhS+YHQe31YeJA2O1F1ygmdv5DLKjeYGV7T4Z6dwrt39EbX1frqepx IouyAclV94FWSrxeg6/Mu5KzCVJvDRwTqNZeIwQHcWdtRRTx3BdEK2RDfKCUb+zVOiPV l/g2rg8FOdFQq+NeXA8NU7J6szjSYiYPXkf1fOdqC62W3ttIcFyEv7/Xvom9AVqYaKHJ LApw== 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=+/vDcQBQhJp5LdSRSfrNgJOMPBZB/NQlrtneT1tdPL4=; b=f1noaNLN0nwVuXoH8zuwteaWgxoOGX8+yThor3CBlwZzy5xw8ajOov+ivykDu0qgwt LxKN/PqY/I+0XDJzmzv/dj9w6jZFKK+QcyvQGhNGlSuinx0BzGDLoTcLheQQzugyfrjC VzFUmcKgZNn8Xt/O4cKyd8H2xyeVsj2OLXKLIIV1DKH494LnOQzWW/5vIHp/uxk1y72q 7u2+MLDJovmr7mX8Fmz/gFo92jf6EIStHbGaMZYuhMSqAa5Agsht9UyNoQMu8sbsHFrd 1GvtAMqVaD+Cl/rDrAhw0tkMsfxxP6a6nNyTsVJB1z8ANHSb/uY6ZffCyUcHEGM0oX07 3qBg== 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 19si1585424wrz.388.2017.07.18.04.51.21; Tue, 18 Jul 2017 04:51:21 -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 19DDD2664EB; Tue, 18 Jul 2017 13:51:20 +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 91EA426718D; Tue, 18 Jul 2017 13:51:18 +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.187]) by alsa0.perex.cz (Postfix) with ESMTP id 6EDF626717C for ; Tue, 18 Jul 2017 13:51:14 +0200 (CEST) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0MVHmU-1d8ZWo2UXO-00Yhzg; Tue, 18 Jul 2017 13:50:08 +0200 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai , Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:09 +0200 Message-Id: <20170718114820.3681255-6-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:NZ2Hyejxtia8lQ60BdW5UE7ODAO/4DHMyW5zvhsQqT2TIKTU7Rk qusLIj/5aS5/2dnWCN8Itx03xr2UUnLL9hE0TnwsYMplFqAE6XTDZHsjp+b7FvF45gF7ghX Xc7NgQahZTj6Krt1p7pTfHPJzr3tsiFGlXm7kUy+Ad8Zzeh2Ns/H3VybpEYTXGFeqKbheEn P1iL+7lGDgwDtesOcwEHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:+ovodo93ikA=:DZ5ksv8Okr+TxARqaDdfCx YACbuxlWJ7tZcuKh+wzo3qdOTQ+aosOhyGNE8oASkj2H/W/+xcfXj3KqSJf0Sh8GJJbvX1rcn GmJrSU+lSlWY2jeq6xJYVTgMhSbJmp4r/T0vKj4LrDkz1rH2DZMuC2k4Rla1HfKOY5WjGtOd1 JcR0zZqdjTcO5KDwDy5ujlceR5Wc6nInSaQcwmxxQGKuK1c88Ko0+bFyRCGY6eMS49inUor5q ACekTd80j9TcARuNRyXdy/urt+/c1hIGpBfwj3sutaYgjJnOm78No1U94kiQchUfQv7R7uYaB 74RoaPk5n6Do5Ut06iB+HnQGkLTTNsX4Jf8fHgu/lNgyyo3T0aychDKEleTBw2i3PQEpmXl4e 2JyERjvVpVdcX9rGl1Kt3APUYGgv0Hg3zG2P9ZeuZar99TimDzoQ/n6do4kDWmz3nATC7tCCf EkXLdbK2izz7eoRlMKihgWPbZnXGVpYVAwKfuJhM8DF3nRVAj5n7MaLTDEDE8Z24C++6ivRtM f49mXoZTyfk6/jL6hMb1bbJrf7N7nJu/HzDz49QmDLN0mSC+KyY6Shzp3BhuRh4L946fcN76x pVu0vm0xiMz3/CmzNvsLAD3LoNycZO60oNWZPEtlAMQDmg06Z4tZ7Tx2dNjTs/25pC1KlUQzr oaZK4ZAsAtMcfN5tIJuBAUNSuH/h3gOZRa5v0r+c+xMFHSvsuXyoSBTWsSIrqJxuVIJILvr6o pZiS89Kc1Ch/mpAcukLlRZ4H9i3CDEdaSvRMhw== Cc: Julia Lawall , Colin Ian King , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Sakamoto Subject: [alsa-devel] [PATCH v2 6/7] ALSA: rme9652: fix format overflow warnings 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 gcc-7 warns about a possible sprintf format string overflow with a temporary buffer that is used to print from another buffer of the same size: sound/pci/rme9652/hdspm.c: In function 'snd_hdspm_create_alsa_devices': sound/pci/rme9652/hdspm.c:2123:17: error: ' MIDIoverMADI' directive writing 13 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] This extends the temporary buffer to twice the size, and changes the code to use the safer snprintf() across the entire file. The longer buffer is still necessary to avoid a format-truncation warning. Signed-off-by: Arnd Bergmann --- sound/pci/rme9652/hdspm.c | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 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/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 254c3d040118..2a3a916e5d15 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -2061,7 +2061,7 @@ static int snd_hdspm_create_midi(struct snd_card *card, struct hdspm *hdspm, int id) { int err; - char buf[32]; + char buf[64]; hdspm->midi[id].id = id; hdspm->midi[id].hdspm = hdspm; @@ -2120,19 +2120,23 @@ static int snd_hdspm_create_midi(struct snd_card *card, if ((id < 2) || ((2 == id) && ((MADI == hdspm->io_type) || (MADIface == hdspm->io_type)))) { if ((id == 0) && (MADIface == hdspm->io_type)) { - sprintf(buf, "%s MIDIoverMADI", card->shortname); + snprintf(buf, sizeof(buf), "%s MIDIoverMADI", + card->shortname); } else if ((id == 2) && (MADI == hdspm->io_type)) { - sprintf(buf, "%s MIDIoverMADI", card->shortname); + snprintf(buf, sizeof(buf), "%s MIDIoverMADI", + card->shortname); } else { - sprintf(buf, "%s MIDI %d", card->shortname, id+1); + snprintf(buf, sizeof(buf), "%s MIDI %d", + card->shortname, id+1); } err = snd_rawmidi_new(card, buf, id, 1, 1, &hdspm->midi[id].rmidi); if (err < 0) return err; - sprintf(hdspm->midi[id].rmidi->name, "%s MIDI %d", - card->id, id+1); + snprintf(hdspm->midi[id].rmidi->name, + sizeof(hdspm->midi[id].rmidi->name), + "%s MIDI %d", card->id, id+1); hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; snd_rawmidi_set_ops(hdspm->midi[id].rmidi, @@ -2148,14 +2152,16 @@ static int snd_hdspm_create_midi(struct snd_card *card, SNDRV_RAWMIDI_INFO_DUPLEX; } else { /* TCO MTC, read only */ - sprintf(buf, "%s MTC %d", card->shortname, id+1); + snprintf(buf, sizeof(buf), "%s MTC %d", + card->shortname, id+1); err = snd_rawmidi_new(card, buf, id, 1, 1, &hdspm->midi[id].rmidi); if (err < 0) return err; - sprintf(hdspm->midi[id].rmidi->name, - "%s MTC %d", card->id, id+1); + snprintf(hdspm->midi[id].rmidi->name, + sizeof(hdspm->midi[id].rmidi->name), + "%s MTC %d", card->id, id+1); hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; snd_rawmidi_set_ops(hdspm->midi[id].rmidi, @@ -6869,7 +6875,8 @@ static int snd_hdspm_create(struct snd_card *card, * when running with multiple cards. */ if (NULL == id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { - sprintf(card->id, "HDSPMx%06x", hdspm->serial); + snprintf(card->id, sizeof(card->id), + "HDSPMx%06x", hdspm->serial); snd_card_set_id(card, card->id); } } @@ -6954,17 +6961,18 @@ static int snd_hdspm_probe(struct pci_dev *pci, } if (hdspm->io_type != MADIface) { - sprintf(card->shortname, "%s_%x", - hdspm->card_name, - hdspm->serial); - sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d", - hdspm->card_name, - hdspm->serial, - hdspm->port, hdspm->irq); + snprintf(card->shortname, sizeof(card->shortname), "%s_%x", + hdspm->card_name, hdspm->serial); + snprintf(card->longname, sizeof(card->longname), + "%s S/N 0x%x at 0x%lx, irq %d", + hdspm->card_name, hdspm->serial, + hdspm->port, hdspm->irq); } else { - sprintf(card->shortname, "%s", hdspm->card_name); - sprintf(card->longname, "%s at 0x%lx, irq %d", - hdspm->card_name, hdspm->port, hdspm->irq); + snprintf(card->shortname, sizeof(card->shortname), "%s", + hdspm->card_name); + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d", + hdspm->card_name, hdspm->port, hdspm->irq); } err = snd_card_register(card);