]> git.baikalelectronics.ru Git - kernel.git/commit
tools/thermal: Fix possible path truncations
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 25 Jul 2022 17:37:54 +0000 (10:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:15 +0000 (14:24 +0200)
commit5fd61d293347a0e226798a9f09691f3089dc9223
tree307e3ff3343945a990face6307915305df819ff9
parente0e193e49e067dfc598ac76c1b89265192cd9c10
tools/thermal: Fix possible path truncations

[ Upstream commit 6d0358f8ac025d1f0898177c03825a9049e9516d ]

A build with -D_FORTIFY_SOURCE=2 enabled will produce the following warnings:

sysfs.c:63:30: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 255 [-Wformat-truncation=]
  snprintf(filepath, 256, "%s/%s", path, filename);
                              ^~
Bump up the buffer to PATH_MAX which is the limit and account for all of
the possible NUL and separators that could lead to exceeding the
allocated buffer sizes.

Fixes: e8658e3e2d63 ("tools/thermal: Introduce tmon, a tool for thermal subsystem")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/thermal/tmon/sysfs.c