From 1b0bfc2bc022d1e50462b2ef6796c7403067f2d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 31 Aug 2018 13:47:36 -0400 Subject: [PATCH] Test fix: check length of input string MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported-by: Coverity Scan (395327 Unbounded source buffer) Signed-off-by: Jérémie Galarneau --- tests/unit/ini_config/ini_config.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/ini_config/ini_config.c b/tests/unit/ini_config/ini_config.c index e9710275b..bf20d1561 100644 --- a/tests/unit/ini_config/ini_config.c +++ b/tests/unit/ini_config/ini_config.c @@ -19,6 +19,7 @@ #include #include #include +#include struct state { int section_1; @@ -81,6 +82,11 @@ int main(int argc, char **argv) goto end; } + if (strlen(argv[1]) >= LTTNG_PATH_MAX) { + diag("The provided path exceeds the maximal permitted length of %i bytes", + LTTNG_PATH_MAX); + goto end; + } path = utils_expand_path(argv[1]); if (!path) { fail("Failed to resolve sample INI file path") -- 2.34.1