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) {