Test fix: check length of input string
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 31 Aug 2018 17:47:36 +0000 (13:47 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 31 Aug 2018 17:47:38 +0000 (13:47 -0400)
Reported-by: Coverity Scan (395327 Unbounded source buffer)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/unit/ini_config/ini_config.c

index e9710275b39bb56e3b5a162228ffd333207048f7..bf20d1561a616bd24b55f8f062d3c09f1fafc1c5 100644 (file)
@@ -19,6 +19,7 @@
 #include <common/config/session-config.h>
 #include <common/utils.h>
 #include <string.h>
+#include <lttng/constant.h>
 
 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")
This page took 0.033552 seconds and 4 git commands to generate.