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;