Fix: possible out of bounds write in enable-event
[lttng-tools.git] / src / bin / lttng / commands / enable_events.c
index 2af85fe476eb74abaf71ea7b456a6ee1723408b1..18793ae095a77cbe8365f09ac0576a06011ea407 100644 (file)
@@ -268,7 +268,11 @@ int loglevel_str_to_value(const char *inputstr)
        int i = 0;
        char str[LTTNG_SYMBOL_NAME_LEN];
 
-       while (i < LTTNG_SYMBOL_NAME_LEN && inputstr[i] != '\0') {
+       /*
+        * 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.
+        */
+       while (i < (LTTNG_SYMBOL_NAME_LEN - 1) && inputstr[i] != '\0') {
                str[i] = toupper(inputstr[i]);
                i++;
        }
This page took 0.023568 seconds and 4 git commands to generate.