Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4295094ima; Mon, 4 Feb 2019 13:50:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJgS2hUzKygWom5CfHeKISrqyZZdUvkuDkUtgJo0KZv9mP1EMwoTged509Xpj9H1Nrj7vA X-Received: by 2002:a62:59c9:: with SMTP id k70mr1455708pfj.243.1549317025348; Mon, 04 Feb 2019 13:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549317025; cv=none; d=google.com; s=arc-20160816; b=YJa4QwZf4v7Q1LzpynR2QziHaJYjUkmG71VBNuFTDspehWFnUzZRVv+AGEnLlvt/Y4 40lObHh3Lv3kRZy0zsZsugGoa63YQUzXsVd179LiK1/ENUifX68ui8WzJgEZoOW4Ypg4 q3m3HgsgID12ySVg3YI1ZQK1Y8g1iwQ6GPBvBveQAfKP8//M4rDK+3S891ny3T7A0c/x desaF4NiKjGQ7ctvZmr0TFzm8wdv33eH8+G3WGHdkeHN58v8oKx+h8hrdTNHMt6BfdAa AgeTmCrR06SON59ikhbFFTRbtmD3Xpo+DL9V56+9nu6g9YsnzTOHhwg/sfbBG2Eu5c0r QGug== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=+Vvq/odzZ/rMGs5KN/mwfwoO1yhskiWdtualpIg0ag0=; b=jBlwQgOcBjqOQMTX4jHpFMFlEzS3RAo7WHRmrSfG2TVPWosfVHxyEo+lU3umtlE6jj C87sbjhsihvGrTr3Orl8BTgaUhEr4xfIokTQfXnzF278lXFdtyKgkm0QKFtC3uAQtdiB rKywKQYPvDh7zzTrq4F1qEgBR3q/mVk0t5csnfAD5woVwlVavM5BCEFkzQZOpAMGvoTD suhRRyavNoScPIJzjKnMxPR+R9InZ6tTZj4Jr2a0BA9YNCBFEg2pzQFMsXsGa75c3Cgs +Ke0Ehz9884kGca7uTR9cvz8k9AKMDwvisr2cKv9l0dbyorLC3F5/kD/JNa9Me1LlvsS 5aCw== 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 c7si1038812pgg.339.2019.02.04.13.50.09; Mon, 04 Feb 2019 13:50:25 -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 S1729374AbfBDUrR (ORCPT + 99 others); Mon, 4 Feb 2019 15:47:17 -0500 Received: from gofer.mess.org ([88.97.38.141]:53053 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfBDUrR (ORCPT ); Mon, 4 Feb 2019 15:47:17 -0500 Received: by gofer.mess.org (Postfix, from userid 1000) id DB7DA60219; Mon, 4 Feb 2019 20:47:14 +0000 (GMT) Date: Mon, 4 Feb 2019 20:47:14 +0000 From: Sean Young To: Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests: ir: fix =?utf-8?Q?w?= =?utf-8?B?YXJuaW5nOiDigJglc+KAmQ==?= directive output may be truncated Message-ID: <20190204204714.pcfoacny7rypgfww@gofer.mess.org> References: <20190131194312.19060-1-shuah@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190131194312.19060-1-shuah@kernel.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 12:43:12PM -0700, Shuah Khan wrote: > Fix the following warning by sizing the buffer to max. of sysfs > path max. size + d_name max. size. > > gcc -Wall -O2 -I../../../include/uapi ir_loopback.c -o ../tools/testing/selftests/ir/ir_loopback > ir_loopback.c: In function ‘lirc_open’: > ir_loopback.c:71:37: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 95 [-Wformat-truncation=] > snprintf(buf, sizeof(buf), "/dev/%s", dent->d_name); > ^~ > In file included from /usr/include/stdio.h:862:0, > from ir_loopback.c:14: > /usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 6 and 261 bytes into a destination of size 100 > return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > __bos (__s), __fmt, __va_arg_pack ()); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Signed-off-by: Shuah Khan Thank you for catching and fixing these. For all three patches: Acked-by: Sean Young > --- > tools/testing/selftests/ir/ir_loopback.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/ir/ir_loopback.c b/tools/testing/selftests/ir/ir_loopback.c > index 858c19caf224..8cdf1b89ac9c 100644 > --- a/tools/testing/selftests/ir/ir_loopback.c > +++ b/tools/testing/selftests/ir/ir_loopback.c > @@ -27,6 +27,8 @@ > > #define TEST_SCANCODES 10 > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) > +#define SYSFS_PATH_MAX 256 > +#define DNAME_PATH_MAX 256 > > static const struct { > enum rc_proto proto; > @@ -56,7 +58,7 @@ static const struct { > int lirc_open(const char *rc) > { > struct dirent *dent; > - char buf[100]; > + char buf[SYSFS_PATH_MAX + DNAME_PATH_MAX]; > DIR *d; > int fd; > > -- > 2.17.1