Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2855983pxb; Mon, 6 Sep 2021 06:55:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysd727jlFC9YfNPT9P/qyG84j3BJvqcCXwnwo3MGwR/m6sA8NJW4o1LaIpHwBaVMdX2SfM X-Received: by 2002:a05:6e02:510:: with SMTP id d16mr8642680ils.13.1630936523762; Mon, 06 Sep 2021 06:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630936523; cv=none; d=google.com; s=arc-20160816; b=iflgpkOXcXqaFC/+D/zKSp8qEg/slXN9xiIiH9V34fZWT/oxfF81Lpr5pBN2PB2mxk VT/GvMXhg9rlIMGHqyTiWYw8YL70O6CkYhR/37OhzlGDvCuwJBSi6snJ7zhMIDmYoT1Q EKc2ueMFU4kPmQGrnW1TKV9F2Wjcw8oNeAkGKN6Tff1CaaMEWITdg5Ug1rlvnd+v8bxm ge8PRX0RtCz+IZBBaN3YM1bhM5nXcm+7PClo9ri4meMajZfzrRQ3xk40ADRonQidqglA p5VikqaguqBUx8GAMYYHQlklV7DwZJz7yDdm319YrGTEAM5pNuI5jOk+NSm+q5vcciXT j1hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=VKbqFGMIfebUpBwKSYqriu62AqpfkR80+NnIuriy5gc=; b=OmzBmo5J7Z99bxx3DwVX/cdjmZ3yUeCxjgbgqS0TtIZR5dZgdL9oO1prbgikUHncr8 oCCgE9TO7FtVo+IrVeibjmdDRisWE/80uzo6HzH3heyzX/4IxIwFC/8ctFu7P0x6e9wZ eQzmbq5VNwOkEkiHjji0zr/K9gOFkDj5mG/KtU1s+z8CWs+lNavqVpaici7xZIfDYGA5 Kb8adc3sO8a41i8dfxiYEp1ds7etrjRgyuSsan3b+48d6Ui5zWGygp7lDoSiRL1Q0L2C exhCx6XBWW2GbuI5mBfTw9wJ77UDXwzZir1O4+bQDfoCGg90HnQSoB2TPB+F1o8LrlK2 7jKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si8466450jaq.91.2021.09.06.06.55.11; Mon, 06 Sep 2021 06:55:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242959AbhIFNut (ORCPT + 99 others); Mon, 6 Sep 2021 09:50:49 -0400 Received: from smtpbg126.qq.com ([106.55.201.22]:14354 "EHLO smtpbg587.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242659AbhIFNut (ORCPT ); Mon, 6 Sep 2021 09:50:49 -0400 X-QQ-mid: bizesmtp42t1630936166t2m8s7l1 Received: from localhost.localdomain (unknown [171.223.98.107]) by esmtp6.qq.com (ESMTP) with id ; Mon, 06 Sep 2021 21:49:25 +0800 (CST) X-QQ-SSF: 01000000004000C0D000B00A0000000 X-QQ-FEAT: TU3YmX8YeZl7wBXBUJR8beZmR+2M+Ak7m3r5yjAGsVbMvtRbVkRCJOFuoKgbD Ss591D9lubapmjzOeqpde/xaVikkf2SRrnd/bS2byizKpfVZ3XvYxUEPyFyKxpsHUWCeiEq HJcuPVfJlmnwHKudyEeJUNZBJ9VrWWTOFX4u/iKFYDLUBmSOfTWkanEq9FDi0/I7TBHoWyw JBH1gl7P/ld1qABxUlIb+nG3/oLdxBBBFpmVmbU2dE7UVP0S+31Pq8JJgsK7mpTx54/D99k z6wn5/QnwX186Z6LJHpmDEj6DhzAUM4y0SaIPBpYx6XN6a9QwhPrPzy4lHZdqbSN68aVU06 YVqIEUU894SH0DWsiM= X-QQ-GoodBg: 0 From: Jason Wang To: zajec5@gmail.com Cc: hauke@hauke-m.de, tsbogend@alpha.franken.de, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang Subject: [PATCH] MIPS: BCM47XX: Replace strlcpy with strscpy Date: Mon, 6 Sep 2021 21:49:23 +0800 Message-Id: <20210906134923.102964-1-wangborong@cdjrlc.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:cdjrlc.com:qybgspam:qybgspam2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The strlcpy should not be used because it doesn't limit the source length. As linus says, it's a completely useless function if you can't implicitly trust the source string - but that is almost always why people think they should use it! All in all the BSD function will lead some potential bugs. But the strscpy doesn't require reading memory from the src string beyond the specified "count" bytes, and since the return value is easier to error-check than strlcpy()'s. In addition, the implementation is robust to the string changing out from underneath it, unlike the current strlcpy() implementation. Thus, We prefer using strscpy instead of strlcpy. Signed-off-by: Jason Wang --- arch/mips/bcm47xx/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/bcm47xx/board.c b/arch/mips/bcm47xx/board.c index 35266a70e22a..74113dcd86e0 100644 --- a/arch/mips/bcm47xx/board.c +++ b/arch/mips/bcm47xx/board.c @@ -345,7 +345,7 @@ void __init bcm47xx_board_detect(void) board_detected = bcm47xx_board_get_nvram(); bcm47xx_board.board = board_detected->board; - strlcpy(bcm47xx_board.name, board_detected->name, + strscpy(bcm47xx_board.name, board_detected->name, BCM47XX_BOARD_MAX_NAME); } -- 2.33.0