Tests: fix: unchecked sscanf return value
[lttng-tools.git] / tests / regression / tools / notification / base_client.c
index fcef66c21a3f062c1a8c1b48c119a25b27ea5c9a..851f42ab37541ee39add45614a0f9febf10406c1 100644 (file)
@@ -42,7 +42,10 @@ int handle_condition(
                const struct lttng_condition *condition,
                const struct lttng_evaluation *condition_evaluation);
 
-int parse_arguments(char **argv) {
+static
+int parse_arguments(char **argv)
+{
+       int sscanf_ret;
        const char *domain_type_string = NULL;
        const char *buffer_usage_type_string = NULL;
        const char *buffer_usage_threshold_type = NULL;
@@ -94,7 +97,13 @@ int parse_arguments(char **argv) {
        }
 
        /* Number of notification to expect */
-       sscanf(nr_expected_notifications_string, "%d", &nr_expected_notifications);
+       sscanf_ret = sscanf(nr_expected_notifications_string, "%d",
+                       &nr_expected_notifications);
+       if (sscanf_ret != 1) {
+               printf("error: Invalid nr_expected_notifications, sscanf returned %d\n",
+                               sscanf_ret);
+               goto error;
+       }
 
        return 0;
 error:
This page took 0.043591 seconds and 4 git commands to generate.