Received: by 10.223.185.116 with SMTP id b49csp2418022wrg; Mon, 12 Feb 2018 09:13:05 -0800 (PST) X-Google-Smtp-Source: AH8x224050iJpsiykTRK9p52lRlXFF9p+5e/hoSptM6tPAKEOBOI7JfeKSMwVMU8MyebWaUL3DZd X-Received: by 2002:a17:902:1683:: with SMTP id h3-v6mr11486061plh.433.1518455585862; Mon, 12 Feb 2018 09:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518455585; cv=none; d=google.com; s=arc-20160816; b=n1OWCYR6QsfIQwHoWdz4RZ0JJxpVtTs5JWDk05/QzVK9OXxjwf4Eae0WqeHrFF2qUb yR53nUe/jlM+N0aBR+LYnZTCuDxVGI1Yi1FXH5QckfD7oEcrjKytYHU63eRAi9PrUcI6 FES/6kpdbkalLiShFlhixZo5eRlnesvPDrk+ZKLl2lZZQ09/gagWs7+sRjuuDEap89nk bq9njDI7YL4zkgupIkJQDLRjtN8yrnrlnvzabvHkqp8N5WayvZOB8FUMBomuTrafWBOV t4XZuCrlL1GnsBQS9Wm6OdeJeuV/REIDL/MtnZpGssbZ8WU2JvvkCfq86AKLO20gCy/b vnQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=qudoj1LkrqgDJPvvXwwjv/0dkWb37tkzu8u7G+yRNhk=; b=AkuJsuhtLgqW8tIIyIM+QKKL1WR1NXLQsJIIqcNhk7a8kdC3B7PrjUINEpGmie6xhe LbZSiket4xztyhgu4ZYvorZGpKW5TC1YCwKahjHrQYvvRgcgQr3qWWd+e+vkuxkJlgHg cFYtc5mS0BwVv2LEUayBqQRv91HlTkQfosBcLxsPTM7OND51KMwYciFTu/g6dJAmkGe1 m8amPmtwImGRJ1GGTAqqGV+MlpYaGKUThcnntCsCmep5YlsJG3G6at8AoI2TP3YbeT4Z bIwYlxRXht3p4J/P4NSYfD5a90MSratOgRC152ivHLngKrN9WiZydeUjC8k9F9qfRLVe k+gQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si2835586plt.26.2018.02.12.09.12.46; Mon, 12 Feb 2018 09:13:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753244AbeBLRLw (ORCPT + 99 others); Mon, 12 Feb 2018 12:11:52 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:40553 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118AbeBLRLu (ORCPT ); Mon, 12 Feb 2018 12:11:50 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id w1CHBbNF031613; Mon, 12 Feb 2018 18:11:37 +0100 Date: Mon, 12 Feb 2018 18:11:37 +0100 From: Willy Tarreau To: Miguel Ojeda Cc: Xiongfeng Wang , Dan , Arnd Bergmann , linux-kernel Subject: Re: [PATCH V2] auxdisplay: use correct string length Message-ID: <20180212171137.GA31601@1wt.eu> References: <1516095490-83827-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 12, 2018 at 01:53:57PM +0100, Miguel Ojeda wrote: > > 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). For me this seems to be the result of yet another very stupid gcc warning trying to dissuade us from using well defined fonctions... it's unimaginable how gcc warnings have become stupid and irrelevant since its developers stopped using C to write it :-( If you want to work around this wrong warning, probably that increasing the destination storage size by one and adding -1 to strncpy() would shut it up but that really becomes quite annoying to have to modify code and storage just to shut down a dumbass compiler trying to be smart. Willy