Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5779567rwb; Mon, 5 Dec 2022 04:08:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nYZvhztJriJ0lqOt+SfT+FRW1fBnHzblCWOIDaKfGDfXIgQvOLIhVLh2qZFNixnuggIlp X-Received: by 2002:a05:6402:550b:b0:45f:9526:e35a with SMTP id fi11-20020a056402550b00b0045f9526e35amr74413057edb.256.1670242086437; Mon, 05 Dec 2022 04:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670242086; cv=none; d=google.com; s=arc-20160816; b=M9nihB204aixk5Nvrq2fH7vTHjsmrY5i8ZovB+uD8rcf1L9/qdHvalQW8T5OxwWVNu mj0ejpYeGM87iyfxNj3pAFiMsjSA+VAaPo/tTQmZCpguJ22ykYebNZKkd72LKBQPY7mm A63I2K+e0O9lzNpLy6nYdeY3+mg+qZW/a6aYRxoiBukftCNO54wjxiKDdyHu+Rn5eE6h VeGejFPDO2Ke1RpaKv2u/HQJydwLKIXdUUaojOOqNicxsEitmGTymRi0weqhow4oTPKc vy3EKY5p2jrZoxhI6hdrhuhKe3wLuDCKJHlneh5tlyP8JvFdjzxw7xvG2YoqfehUjA3J hZYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=e2S8z4PTEdKEwv/rAmo0AY87DUNy2YbhBLUi2cKCNYQ=; b=KIQ7Ke1uEhZD08BSoNRVU4BgQkA5F6AZLcbCe7svWr0j0SRHhVHuW+D5KHVTyb3LKP KITx06mvfuOAjTWPeLfCIYc2h8aUH6l+q4ySzDDJohHtBYzLhgCfkXGH2qCqs/3N2HQb IfrhfNfDu/pBDbn7GMXOxmTTXqk7GdCL0CaM6XcFlLJIuGjTyHNE8t9yTTkYJ0P1qmZ1 D1TGLcVydCSjDRATZpT5txh5FSD60FUOM007HRhh1zHSH+95gCVLnNTpMVxzmCSCfUq+ 2eYd5c1I0vMfgsX8r063cJZpjuo4YN4gHJCUdrmViRlz8jFglx0cIVM8lVuvxxiiXry1 2NMQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a05640235c600b0046aeca41c55si12782852edc.212.2022.12.05.04.07.43; Mon, 05 Dec 2022 04:08:06 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230511AbiLELfg (ORCPT + 82 others); Mon, 5 Dec 2022 06:35:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbiLELfe (ORCPT ); Mon, 5 Dec 2022 06:35:34 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 385F319C39 for ; Mon, 5 Dec 2022 03:35:33 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NQhLW55hCz5BNRf; Mon, 5 Dec 2022 19:35:31 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl2.zte.com.cn with SMTP id 2B5BZQN8074822; Mon, 5 Dec 2022 19:35:26 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Mon, 5 Dec 2022 19:35:28 +0800 (CST) Date: Mon, 5 Dec 2022 19:35:28 +0800 (CST) X-Zmail-TransId: 2b04638dd780ffffffffbef9d1e3 X-Mailer: Zmail v1.0 Message-ID: <202212051935289159302@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGRybS9tb2RlczogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2B5BZQN8074822 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638DD783.000 by FangMail milter! X-FangMail-Envelope: 1670240131/4NQhLW55hCz5BNRf/638DD783.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638DD783.000/4NQhLW55hCz5BNRf X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY 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 From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- drivers/gpu/drm/drm_modes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 3c8034a8c27b..cb08b247d8c3 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2081,8 +2081,7 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, break; } - strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); - out->name[DRM_DISPLAY_MODE_LEN-1] = 0; + strscpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); } /** @@ -2123,8 +2122,7 @@ int drm_mode_convert_umode(struct drm_device *dev, * useful for the kernel->userspace direction anyway. */ out->type = in->type & DRM_MODE_TYPE_ALL; - strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); - out->name[DRM_DISPLAY_MODE_LEN-1] = 0; + strscpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); /* Clearing picture aspect ratio bits from out flags, * as the aspect-ratio information is not stored in -- 2.15.2