Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4554152ybi; Tue, 30 Jul 2019 04:08:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhAasPgfl/Iwjo7HqFxDiEz7Id5Iz6VgBGc8s3ccGk+9clKRYhI8jYGGxRDcjQ2KzKzuxT X-Received: by 2002:aa7:81ca:: with SMTP id c10mr41744144pfn.185.1564484921549; Tue, 30 Jul 2019 04:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564484921; cv=none; d=google.com; s=arc-20160816; b=TNIOC3bb+/JMkBdQLB+rybTEEzooCz0p8CcOsFtNuPLP0UfBa0nxEDUVOZqgTWkMG7 l8t2SYQ3gNEfKCsRPqr70Mgc1Z3KO5aUCATlnLLEyWmPgNNo075EBME7LlgZ2a6AnItg 5r4Op95dFAvL4aas6Ai8dww3HR7aBtaYihQXOuL17uo3KSQhlYMW4Kz2EvOJ6zGA9+i4 E2/rbO6a0zobLswfM5Wlpyf38cFUMpUbShn8JZPkJpCI5BXTnmVYHPkw2mE7fCl51X2D sifUr69XAHe8KB6P0CnmnVgmGSf28HJx2zipM2lsQP+IKAgxyFDzvL7RE8t/XAiTFZ1l UzbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=oht354i7nlKO87/dRT8d2R9vughNR8TfvgXEqGm1tuc=; b=CF86Www8iHS2N25qY6c9Kttp/L7jjtU2IvKsD2vu/RYXo83xy2IsQ7z2RDLomlbKQR QLMr35FPV5G+Ab2PsGnDmpOTYj/LrOKcpQaIcQdLxrsva29KUwFFnx/f76WUwk+Cu97k 4+Qid1gpxXQXA0JfGNcf1x6TFswz/wcOSCElRzeB8KfhD+QQnjlmGaTXb4EjakE5/x6g D8ELvt+r9zXVEyQTHtkfk1kCM1i5YfqriJWMZ6dL++CTTGQbpwfkO8NR0uf5QJvGh+fn Bx6zYKiDU5P61B8rXtmWWzbFUNXnbmlMGWQ5qZjL4HndrF8DfhRFF4RJ5L+JQQeCYgub VHfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="HA5f+/Wo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si28778837ple.161.2019.07.30.04.08.27; Tue, 30 Jul 2019 04:08:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="HA5f+/Wo"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730992AbfG3Ikx (ORCPT + 99 others); Tue, 30 Jul 2019 04:40:53 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33663 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbfG3Ikx (ORCPT ); Tue, 30 Jul 2019 04:40:53 -0400 Received: by mail-pg1-f193.google.com with SMTP id f20so20454950pgj.0; Tue, 30 Jul 2019 01:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oht354i7nlKO87/dRT8d2R9vughNR8TfvgXEqGm1tuc=; b=HA5f+/WosIJHoAnUdpExXjkFvcjZ8PqeonpPEaug0kxLT+HDAG5PFC8VSZbbPacAqB tnpBGfCnOIU2ghnvy5ooo05Pd/VcuiM6yCrMm66kbs5Kpa+7b72A8+vhG5O6584koEJc 9xLpvRLXMwd5NzrkgiXErFub01sC9pr/2nmwONgOLu3Zyntyr0lTC1ZgBg8ack9FmeB/ BCluqjV7XsJ0l+V7LNNXaj22P3I3FtMKvsu2L/r/TtsnZuIRb7T5VruDuj1lyHxBiEpN JlB5xbZ9TgWM2EXHUKZu+Wa9Ng3z4ULnBd9QWq5/wlGY7ODwLCxI0V9lxDiC5CaRGBYW O+jA== 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:mime-version :content-transfer-encoding; bh=oht354i7nlKO87/dRT8d2R9vughNR8TfvgXEqGm1tuc=; b=CAGH/6LBykFXzr9PRi6tLLMhDAni1wE1k+ya8naf4h2NhaLcDIjNHn8uYzY+t+WJdG WxeBmblthucaBgHtQgjUbtRytHkI/iLWASdueHxcT3pjjOoWo6QjmrnuCE3GL89faBND W9FUgcndzEyNhWA7yMjd4kmAsEozY0jtpqY4+RjPya0C6+/nP1imQwMFDEKsh/sr57D0 CsFkXtP8ReuGc+Ev8i+4zhYBtdkDvogweXY/sBMNRfzvOvPo8rYWOnaW4uLvy71i9WML HPVp+Va9nVch8QcCchXc8rhv/wFqrND47GaqMwnPjjnyYMyq2DwyHp01CwtYwp7sh+zL /Hbw== X-Gm-Message-State: APjAAAWTFje4O3hfG/yksN3PW8VHEbncmBEU2+TA+yFiVPVISQlt5JY5 DppxKaQjHJe7RiMxd/m1pqs= X-Received: by 2002:a63:ab08:: with SMTP id p8mr18894180pgf.340.1564476052524; Tue, 30 Jul 2019 01:40:52 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id m9sm108158454pgr.24.2019.07.30.01.40.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 01:40:51 -0700 (PDT) From: Chuhong Yuan Cc: Adam Radford , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH] scsi: 3w-sas: Fix unterminated strncpy Date: Tue, 30 Jul 2019 16:40:47 +0800 Message-Id: <20190730084047.26482-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strncpy(dest, src, strlen(src)) leads to unterminated dest, which is dangerous. Here driver_version's len is 32 and TW_DRIVER_VERSION is shorter than 32. Therefore strcpy is OK. Signed-off-by: Chuhong Yuan --- drivers/scsi/3w-sas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c index dda6fa857709..96f529c613a6 100644 --- a/drivers/scsi/3w-sas.c +++ b/drivers/scsi/3w-sas.c @@ -1328,7 +1328,7 @@ static int twl_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset) } /* Load rest of compatibility struct */ - strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); + strcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION); tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD; -- 2.20.1