Received: by 10.223.185.116 with SMTP id b49csp2190362wrg; Mon, 12 Feb 2018 05:57:24 -0800 (PST) X-Google-Smtp-Source: AH8x225R+kIqmo28+fsqSJKT23lrtBXgj2Tx2BiPXwA2wwWnrcl0kf2O9QWonoxix2jkxus4TZT7 X-Received: by 10.101.64.193 with SMTP id u1mr9580754pgp.24.1518443844529; Mon, 12 Feb 2018 05:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518443844; cv=none; d=google.com; s=arc-20160816; b=KqKZX/711fqXIxMebS4qg6wFoNXzy2CxWXw77FlU8B8nRk5oPSUMEehhAQr4JI/O9I wtl4Jb9pqLIkh3Nszq6PpkyQ4pBS/KQ/+rRIvxf4rCik7zSOdMhg3ZIxmeuO0UQaf3nC RE1vbt81vMFfWqiNKAs9LNcFxFLz5nkbdk7k2ZErtt3EFmbQYV+CfIBnC8QqzRuGyfFm KoURL1gXde9KHi7hytFmJMiZe64qJwkvy7WZfhqyTe1opUb5h9ORiSlcTjE51LzhcUBL qsf2t+qp19qtUzfnflESRGkX5MX4IDb9LzW826MuuxfbuiZDRRZF2W7lMX5wyDER07Ff /Rcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Ito9o+pwg7rH6t2jKWQp1Lms9fWQrky0pf4a3sU5WtE=; b=IXLSSx4WMMyqFT9b5e7xz5C/9RLLV0+BQXf2hl5ryh/CyCbHnnclLrlbNAWCXE+mt7 VWmLm2WSVUamzHQacLuZhua5MAVdUmBoz0lRmN4ZowPR5k+LlDwe2jybnHZOaW8qJQvb UZC+kp4CU/EQy/kMdW6h/8zaJmBu8qpcSuoDnoeiQjnvdaooR/sHUnEc3r8VJcLBL8cW iCf8TSsAWnXfyBp7NSYOe80YM/wHOemSaRBzM4GtrJcmeUebt6GWoAZKmZrcREyxMGPq r0YUvhxpz3PYazMf2JN8B0LMWEg9WBjCAIi8Z4TCM8qmkH3m4tBPja8OSuObNGtrQP/w Tnvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kTUCFfTW; 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=pass (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 m2-v6si793708plt.418.2018.02.12.05.57.09; Mon, 12 Feb 2018 05:57:24 -0800 (PST) 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=pass header.i=@gmail.com header.s=20161025 header.b=kTUCFfTW; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934880AbeBLMyP (ORCPT + 99 others); Mon, 12 Feb 2018 07:54:15 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:43274 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934856AbeBLMx6 (ORCPT ); Mon, 12 Feb 2018 07:53:58 -0500 Received: by mail-qt0-f194.google.com with SMTP id d26so8286226qtk.10 for ; Mon, 12 Feb 2018 04:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ito9o+pwg7rH6t2jKWQp1Lms9fWQrky0pf4a3sU5WtE=; b=kTUCFfTWVBxCdLmKHvvi4jpJ+Zs+oUpOHFvAcFBDe4WEX5JWudfciCx9dRPqzzUXEP DkaYHtX2qnl6Gihe5yOSx8IQdJz19tZ7e9D8g+2VVj3oRg18CvNAVsJkx/mmwNs29zRh 5TgVSvf6duH3GcF81vU9KmmBeYUkh3Tssrfo+XaDYG7+sgDQfVfhgV0O7xKRmRwjLvbE Rwp10bFvun7FDKXuumIU7Zx+YUQsdTyMRih4Gu7MPo7v5Z7k3VpvXCTYUMQYlZ8yU8Za zNdIiIqF/AeEckjiBwe4NDdBk0EL3mef9QuFZncZFtrDGJwT2ZSrJzHlJNTnWU7LYJM6 WRTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Ito9o+pwg7rH6t2jKWQp1Lms9fWQrky0pf4a3sU5WtE=; b=n2ePRG6z0SvMBaZ5F9rzOkFSY4n6kZR5OH55z/nMkxhyI5hdzC1+IOyE9uNETywe+6 uH7IUNB05FWzjrBqhI3KhQzg3DItfrczifeB0qrC8e1FNOKWYSACtZx9KgMzGIwtX9Ls DGdVwHCF1Y3n+wKPrc5yLOxh/ehbJr+EOjA1ZOx8ZPm6Ld4r2atoYNGXA5Eswaqg5c+P vHLb3N7rmvleOFx0oYxM/lXf+hZpUXIvAf7/vEIXrlInKywqxdaYaZKVDcX7L9bCbF2p B57P5uTdoUk7bnE0DVGbAN1sMyq0mP286WPaqXUdbZ1eMaxiscbkqOiyrhdTRWK/W+RA Hm6g== X-Gm-Message-State: APf1xPBab8JbQX5buYB626Ln8Bbw4jBODJLivgrKC9l628J0dxRmJkjt F7UnNuxPr4uvMelVXm8o6kIyh0HbyP6hlkAYdyg= X-Received: by 10.237.39.102 with SMTP id n93mr2618262qtd.323.1518440038077; Mon, 12 Feb 2018 04:53:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.52.247 with HTTP; Mon, 12 Feb 2018 04:53:57 -0800 (PST) In-Reply-To: <1516095490-83827-1-git-send-email-wangxiongfeng2@huawei.com> References: <1516095490-83827-1-git-send-email-wangxiongfeng2@huawei.com> From: Miguel Ojeda Date: Mon, 12 Feb 2018 13:53:57 +0100 Message-ID: Subject: Re: [PATCH V2] auxdisplay: use correct string length To: Xiongfeng Wang , Willy Tarreau Cc: Dan , Arnd Bergmann , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 16, 2018 at 10:38 AM, Xiongfeng Wang wrote: > From: Xiongfeng Wang > > gcc-8 reports > > drivers/auxdisplay/panel.c: In function 'panel_attach': > ./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified > bound 12 equals destination size [-Wstringop-truncation] > > We need one less byte or call strlcpy() to make it a nul-terminated > string. > > Signed-off-by: Xiongfeng Wang > --- > drivers/auxdisplay/panel.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c > index ea7869c..d288900 100644 > --- a/drivers/auxdisplay/panel.c > +++ b/drivers/auxdisplay/panel.c > @@ -1506,10 +1506,10 @@ static struct logical_input *panel_bind_key(const char *name, const char *press, > key->rise_time = 1; > key->fall_time = 1; > > - strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); > - strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); > + strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str) - 1); > + strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str) - 1); > strncpy(key->u.kbd.release_str, release, > - sizeof(key->u.kbd.release_str)); > + sizeof(key->u.kbd.release_str) - 1); Are you sure about this patch? `kbd` says "strings can be non null-terminated". Willy, maybe those should just be memcpy()s? (unless the remaining bytes, if any, must be 0). Thanks, Miguel > list_add(&key->list, &logical_inputs); > return key; > } > -- > 1.8.3.1 >