Fix: possible use of uninitialized data in loglevel conversion funcs
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 26 Mar 2015 19:07:35 +0000 (15:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 26 Mar 2015 22:08:17 +0000 (18:08 -0400)
str will be uninitialized if inputstr[0] == '\0'

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/enable_events.c

index 92ca76272bb54e78d40e432d674cc1c933f39b43..1b3d5f7cd7d5d124d60dd95ac1e782f2363c778f 100644 (file)
@@ -334,6 +334,10 @@ static int loglevel_log4j_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
+       if (!inputstr || strlen(inputstr) == 0) {
+               return -1;
+       }
+
        /*
         * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
         * added at the end of the loop so a the upper bound we avoid the overflow.
@@ -373,6 +377,10 @@ static int loglevel_jul_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
+       if (!inputstr || strlen(inputstr) == 0) {
+               return -1;
+       }
+
        /*
         * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
         * added at the end of the loop so a the upper bound we avoid the overflow.
@@ -414,6 +422,10 @@ static int loglevel_python_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
+       if (!inputstr || strlen(inputstr) == 0) {
+               return -1;
+       }
+
        /*
         * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
         * added at the end of the loop so a the upper bound we avoid the overflow.
@@ -450,6 +462,10 @@ int loglevel_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
+       if (!inputstr || strlen(inputstr) == 0) {
+               return -1;
+       }
+
        /*
         * Loop up to LTTNG_SYMBOL_NAME_LEN minus one because the NULL bytes is
         * added at the end of the loop so a the upper bound we avoid the overflow.
This page took 0.02587 seconds and 4 git commands to generate.