Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5648204img; Wed, 27 Mar 2019 12:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4cl4nOX7ctfuHJCMysxVHdMrbAjVKD+QVbTkaQRE8A9N3R07bUp3AN8uWfJ/13syhZAQQ X-Received: by 2002:a63:c54a:: with SMTP id g10mr14182845pgd.71.1553714648865; Wed, 27 Mar 2019 12:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714648; cv=none; d=google.com; s=arc-20160816; b=chDVAjeJkeCSQL2cBaYLYyR6OpUuBrrW77xaCwC2qo8sDLZejs2ivaLzWaqY0TSGJe jP1DqmsQts0zbUrFrL0+ozCzvoYd9PEofZXKH2mQkGwUYuC0XoBRTibNT241ysDSjWn1 bDYMYA/CA7L+qnY/ynxbaODvjt4E9bSMPoBeZAo7MeCjL9v1SktTY1VcQewma9yRXvcJ m67IM4K39rVqCY0UvciijQy9Jq3kV+JRl8Cjf1vGLaOgPZ741yy77tCR6ItMGY6Wc3jQ RhJmaN7Xk3YJKza3aAPrAg2tZMCQn2YkEZozDxPLxEnznC4bX7nY2xF62qIgdn6z5FsY Xq6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DDWhCw/GwmIhFLZ65CG28VVo2agbBUY2h3SRhFBWlNw=; b=Xi1pUs1YEipZEoJjRHQdjC9AFSGuraeRv65nHFbWAKI/2w6rXNb991Z0GgGeAXfl+J +TEY19YD4l+UCAKx8Ru1Jvwp8YbodjFdW9vs61EYpnMF/QL+dtBHWiAMUPu+q4CyTJHY hrIDP9wCmHjL6IlPT0noPnSyor2Im94wZb4mjra1MZpgiG7tuSNHkOT0YazGhPUMjayx tNfoWRjVtNxj1v9M8D3tnXppq4fscAYMWpl2ngn3g3KEyKyGt/8RiJSa15OAZ5dNkkhl yxWlk7kLJkLtU8enddcXxeg1bMCnUk+HJMYKqDQCTjBjHIrASwAxpH9ZkhtCSTVs8x4K 2Z1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mGJE040D; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r63si11370947pfc.183.2019.03.27.12.23.53; Wed, 27 Mar 2019 12:24:08 -0700 (PDT) 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=@kernel.org header.s=default header.b=mGJE040D; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388102AbfC0TWJ (ORCPT + 99 others); Wed, 27 Mar 2019 15:22:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733214AbfC0SGg (ORCPT ); Wed, 27 Mar 2019 14:06:36 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8FFA2063F; Wed, 27 Mar 2019 18:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709995; bh=Aw51D3dFq+SHYFP4bkygBxYF3FzCG3/YZ0jZlOKBKEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGJE040D6aM8xh0/QciPU2Hgq8Uq/6XbaEw2PPsxoujRd7PJ/sMWtHEnbBrLk4Pw6 mxMz/Du6T603XNMXj7LLbIRQDqtMPmUVyTvO6qwbhHw6YfNRbNtxLF64vyO+k84rJU 3HEj6Ab01c2bWYI6p2wlYYBOHS3ycHMdxZ8KYmpk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shuah Khan , Sasha Levin , linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 148/262] =?UTF-8?q?selftests:=20ir:=20fix=20wa?= =?UTF-8?q?rning:=20"%s"=20directive=20output=20may=20be=20truncated=20?= =?UTF-8?q?=E2=80=99=20directive=20output=20may=20be=20truncated?= Date: Wed, 27 Mar 2019 14:00:03 -0400 Message-Id: <20190327180158.10245-148-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuah Khan [ Upstream commit ed675ed9da6d951322efd72d739d6b5ce1c18f02 ] 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 Acked-by: Sean Young Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- 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.19.1