summaryrefslogtreecommitdiff
path: root/tests/tools_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tools_test.c')
-rw-r--r--tests/tools_test.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/tools_test.c b/tests/tools_test.c
index e3f73ac2..08b5626f 100644
--- a/tests/tools_test.c
+++ b/tests/tools_test.c
@@ -77,7 +77,8 @@ static bool chdir_to_tools_dir(void)
igt_info("Failed to cd to %s\n", TOOLS);
/* Try TOOLS and install dir relative to test binary */
- if (readlink("/proc/self/exe", path, sizeof(path)) > 0) {
+ memset(path, 0, sizeof(path)); /* readlink() does not append NUL */
+ if (readlink("/proc/self/exe", path, sizeof(path)-1) > 0) {
igt_info("/proc/self/exe point to %s, going to dirname()\n", path);
chdir(dirname(path));
}