From patchwork Tue Sep 11 18:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10596127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 614E6920 for ; Tue, 11 Sep 2018 18:05:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4651C29BB6 for ; Tue, 11 Sep 2018 18:05:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A3FE29BE7; Tue, 11 Sep 2018 18:05:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E270B29BB6 for ; Tue, 11 Sep 2018 18:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbeIKXGQ (ORCPT ); Tue, 11 Sep 2018 19:06:16 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:43393 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbeIKXGQ (ORCPT ); Tue, 11 Sep 2018 19:06:16 -0400 Received: by mail-qt0-f196.google.com with SMTP id g53-v6so29185412qtg.10 for ; Tue, 11 Sep 2018 11:05:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=frRqL3gXTVynBijbSg3IhiObefKTSIflFFkVaehCekg=; b=WQuJRO/IKv2RnWXLDBcwpoci+/ELkGMXJK7S9bCyT1E97LJEb4s9uq42bD8u767eGy pHuJTuvdw5grI48odex+IU1TDrF7ZwxWD1UQ3+XRyqLDzUn23r3B1YvrA5ZfhHIq0SJM aKfTfMuYMVxYLoaMx7BhdX6MIDpyBJVhX3kWz3wvm2zQ6BDac8tWKHBtS6bYfwSLNoFR bI5YceXBJlhZ/6MMnTlTG9uqjCbbhQ8bp4+xz5PxswYqfLiqlgll2vyEWgPmCfF8qvq5 ziYDdw9/+qYXSsxrueqgkhxKHN71ZeIq1ZWhBxulJKKw1yWGshMigaMtDb0j6l8xSX44 BYyw== X-Gm-Message-State: APzg51AwFJ32BaqfaIqcm1ElmGWDuTWdXOkkEepHm2k89G/8lhbZTZM6 wsu3dK61l53+s13VZhCylg5pFQ== X-Google-Smtp-Source: ANB0VdbhjY7la/0YpYC7b48xbdqfJo4JCXtw9hLBDmsR97vKOa4y62zr3ftarc9cyPhVTcpeGT0twg== X-Received: by 2002:a0c:b584:: with SMTP id g4-v6mr19486585qve.94.1536689148808; Tue, 11 Sep 2018 11:05:48 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::42c3]) by smtp.gmail.com with ESMTPSA id i19-v6sm184875qtf.87.2018.09.11.11.05.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 11:05:47 -0700 (PDT) From: Laura Abbott To: "Bryant G. Ly" , Michael Cyr Cc: Laura Abbott , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Prarit Bhargava Subject: [PATCHv2] scsi: ibmvscsis: Fix a stringop-overflow warning Date: Tue, 11 Sep 2018 11:05:42 -0700 Message-Id: <20180911180542.7778-1-labbott@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's currently a warning about string overflow with strncat: drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c: In function 'ibmvscsis_probe': drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3479:2: error: 'strncat' specified bound 64 equals destination size [-Werror=stringop-overflow=] strncat(vscsi->eye, vdev->name, MAX_EYE); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Switch to a single snprintf instead of a strcpy + strcat to handle this cleanly. Signed-off-by: Laura Abbott Reviewed-by: Kees Cook --- v2: Swtich to using snprintf per suggestion of Kees --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index fac377320158..9305440a00a1 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -3474,8 +3474,7 @@ static int ibmvscsis_probe(struct vio_dev *vdev, vscsi->dds.window[LOCAL].liobn, vscsi->dds.window[REMOTE].liobn); - strcpy(vscsi->eye, "VSCSI "); - strncat(vscsi->eye, vdev->name, MAX_EYE); + snprintf(vscsi->eye, sizeof(vscsi->eye), "VSCSI%s", vdev->name); vscsi->dds.unit_id = vdev->unit_address; strncpy(vscsi->dds.partition_name, partition_name,