diff options
author | Seth Forshee <seth.forshee@canonical.com> | 2017-09-28 09:34:26 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-10-06 20:51:10 +1100 |
commit | 06755a871314c7443a89c09650cdb3982466e1a8 (patch) | |
tree | 62c6f08d3b7b9b3091940eea17a7bd82cfaa44c7 /tools/testing | |
parent | 186b8f1587c79c2fa04bfa392fdf084443e398c1 (diff) | |
download | linux-stable-06755a871314c7443a89c09650cdb3982466e1a8.tar.gz linux-stable-06755a871314c7443a89c09650cdb3982466e1a8.tar.bz2 linux-stable-06755a871314c7443a89c09650cdb3982466e1a8.zip |
selftests/powerpc: Use snprintf to construct DSCR sysfs interface paths
Currently sprintf is used, and while paths should never exceed
the size of the buffer it is theoretically possible since
dirent.d_name is 256 bytes. As a result this trips
-Wformat-overflow, and since the test is built with -Wall -Werror
the causes the build to fail. Switch to using snprintf and skip
any paths which are too long for the filename buffer.
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c index 17fb1b43c320..1899bd85121f 100644 --- a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c +++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c @@ -53,6 +53,8 @@ static int check_all_cpu_dscr_defaults(unsigned long val) } while ((dp = readdir(sysfs))) { + int len; + if (!(dp->d_type & DT_DIR)) continue; if (!strcmp(dp->d_name, "cpuidle")) @@ -60,7 +62,9 @@ static int check_all_cpu_dscr_defaults(unsigned long val) if (!strstr(dp->d_name, "cpu")) continue; - sprintf(file, "%s%s/dscr", CPU_PATH, dp->d_name); + len = snprintf(file, LEN_MAX, "%s%s/dscr", CPU_PATH, dp->d_name); + if (len >= LEN_MAX) + continue; if (access(file, F_OK)) continue; |