From patchwork Thu Oct 20 05:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuijinpeng666@gmail.com X-Patchwork-Id: 5977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp83098wrs; Wed, 19 Oct 2022 23:00:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DKStzziSaXjEuvQ96Cmpl74x8dS0abz4GIWO0PRWY0GNHMsqPW/uanJwdndICi0OHfTHz X-Received: by 2002:aa7:ca45:0:b0:458:d9a2:6164 with SMTP id j5-20020aa7ca45000000b00458d9a26164mr10851532edt.340.1666245612345; Wed, 19 Oct 2022 23:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666245612; cv=none; d=google.com; s=arc-20160816; b=GuKYz4U1CVdvlI4MQeZwczJeHcaTc+s92u/wMxWnJXvF8pBBk04DIgOHAS6hWt9Tzx TwV1G7fMcfnP59f3bUnnw2IcYWSUFLzYrGl64/LMn8vGyaP8gjF/F2dboyjmsXAaGAgw yGS86KUq5mTuEd/z1NhYr5luJBnE2AMpn1rtX2ufM1bA5bib/WO4R4Lid2MsHfZkq+eq T5bsEndtIN6zorOahZC7P2MQIB80KcUZfOxeBfzKN5T6R5hQdUsFVUOJuht7Ydxsk0yS stQn4V5IUMS1vOJ9d2nI/rPLIWDOB32rBJxAsqvWk4/tZ7Se6g3sPg91EPPT02ToUDXR nJ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ovO4Wn2KciXjhfhIU1Ht+t+UirFlYYyzrqGDJdPLqqI=; b=fTuM9rq9MlQ7wRFZx93Yr/kA5QztoUUS++H3hzevkIyvjl6NadNB/q5+hkcR15GeMv KMYR1y6ttzXPRYLVwy2R2oclcODwd8WVDdJvPXovEBq+pNbAg6AM2YrqjF0tpa5tE6gD /s7Pz1uTB/SNXKyoQSD+yfx5Kf2DJw1n5jL+3VzIruac/4PKNpkJmDGD+moWkgNPP/wR lllTXfm4H+VSvPkYrJjsQn5788E2KyaxzUJHL/s8ZHhsLLLJk1tIlIB7Wf7cpADeNNiG iLl/USuJRnQ7+p5dEklY4CwlCdAI5et3W34dnDgkak6YM18+VLNxY6DKrPaXYvIvkVBN bQTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ko+4G9In; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d22-20020a50fe96000000b0045beaf03ddesi13807982edt.411.2022.10.19.22.59.45; Wed, 19 Oct 2022 23:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ko+4G9In; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbiJTFrE (ORCPT + 99 others); Thu, 20 Oct 2022 01:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiJTFrD (ORCPT ); Thu, 20 Oct 2022 01:47:03 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E53CB159D5F; Wed, 19 Oct 2022 22:46:58 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id e129so18272363pgc.9; Wed, 19 Oct 2022 22:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ovO4Wn2KciXjhfhIU1Ht+t+UirFlYYyzrqGDJdPLqqI=; b=Ko+4G9InvfhExZOlJfPtkMVy/D5gdhgAia6F8iPargASMfbh6TDIkDbuK6cxdw5MUI 6IAiGIKEEoodin9JQjbz4cFOq0loHWMlsMPs6EpJDR7+IRrAzRNDOEl9PTDKJPQpOgq1 cdXUH05ZeMS9Rq+xGcQ/cfjjjeOZIY4rAfNrVhIx+sUvXHZvjCaAk40IhmZzfAhFm2dt uGxoHw+EOvF4C5aCq1OCafCBUUP093CdYJYYDNpab1RsU3EhQELMmAUzWjuL3aw569Mt CNP/xTEjj27zgCAjwatHvaL1XRTHyKoqlSOv3EoYAASFFEP419W8tttiP7R340T0kGPo ErkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ovO4Wn2KciXjhfhIU1Ht+t+UirFlYYyzrqGDJdPLqqI=; b=h21fgMfG731dh3HlLi/zj79RbzTg2hbquaoojkJFRFg0p8BPWheLTPntNIkCSA56qJ S2Dsy1q81PNOMjlRNsMO+J1R+C+LCB3vZYiyRk2Xdwey3ncQLxFWJVqJwe17TP+qG1So uQgiy60/AB9qkI/Tqsm0E5OSJnFtD/EMqv1GdPxXVawIDs25LMIsapWdrDyPxRWJZByj +uesG5+cAHL708VubJwMGV4zxhFf5XlMczgAscYF52av2HOjdXkQtf+f2yxDsXqAePg0 aTRvDFL6rQu/6WPHqwbYNALBdO7/KBa5wDvgJAX1aP1/p3uuX5kyAgh3BHLsRfwfeM6s eKXw== X-Gm-Message-State: ACrzQf3yuuKxW1ogszIlCvm1G5YVOtozK914EMXoR3cpoIzK1Rm1M45i +mfXrRX63BVpx/XYB+jtbDL6PvoeIno= X-Received: by 2002:a63:194b:0:b0:457:7295:8de0 with SMTP id 11-20020a63194b000000b0045772958de0mr10618087pgz.612.1666244818452; Wed, 19 Oct 2022 22:46:58 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id r16-20020a63e510000000b004308422060csm10651732pgh.69.2022.10.19.22.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 22:46:57 -0700 (PDT) From: cuijinpeng666@gmail.com X-Google-Original-From: cui.jinpeng2@zte.com.cn To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: target-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Jinpeng Cui , Zeal Robot Subject: [PATCH linux-next] scsi: target: core: use strscpy() is more robust and safer Date: Thu, 20 Oct 2022 05:46:50 +0000 Message-Id: <20221020054650.394396-1-cui.jinpeng2@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747185159123606491?= X-GMAIL-MSGID: =?utf-8?q?1747185159123606491?= From: Jinpeng Cui The implementation of strscpy() is more robust and safer. Reported-by: Zeal Robot Signed-off-by: Jinpeng Cui --- drivers/target/target_core_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index b7f16ee8aa0e..0eec5a3217b9 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -809,10 +809,10 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) xcopy_lun->lun_tpg = &xcopy_pt_tpg; /* Preload the default INQUIRY const values */ - strlcpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor)); - strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod, + strscpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor)); + strscpy(dev->t10_wwn.model, dev->transport->inquiry_prod, sizeof(dev->t10_wwn.model)); - strlcpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, + strscpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, sizeof(dev->t10_wwn.revision)); return dev;