projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: tests: base notification client: unchecked sscanf return value
[lttng-tools.git]
/
tests
/
regression
/
tools
/
notification
/
base_client.c
diff --git
a/tests/regression/tools/notification/base_client.c
b/tests/regression/tools/notification/base_client.c
index f74657a2aefb2c878d054b23f9d404eac8112b68..9b6d30b86731cb638d21f37c77d9932ce18a0b7d 100644
(file)
--- a/
tests/regression/tools/notification/base_client.c
+++ b/
tests/regression/tools/notification/base_client.c
@@
-17,7
+17,7
@@
#include <assert.h>
#include <lttng/action/action.h>
#include <assert.h>
#include <lttng/action/action.h>
-#include <lttng/action/
group
.h>
+#include <lttng/action/
list
.h>
#include <lttng/action/notify.h>
#include <lttng/condition/buffer-usage.h>
#include <lttng/condition/condition.h>
#include <lttng/action/notify.h>
#include <lttng/condition/buffer-usage.h>
#include <lttng/condition/condition.h>
@@
-36,7
+36,7
@@
static const char *channel_name = NULL;
static double threshold_ratio = 0.0;
static uint64_t threshold_bytes = 0;
static bool is_threshold_ratio = false;
static double threshold_ratio = 0.0;
static uint64_t threshold_bytes = 0;
static bool is_threshold_ratio = false;
-static bool use_action_
group
= false;
+static bool use_action_
list
= false;
static enum lttng_condition_type buffer_usage_type = LTTNG_CONDITION_TYPE_UNKNOWN;
static enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
static enum lttng_condition_type buffer_usage_type = LTTNG_CONDITION_TYPE_UNKNOWN;
static enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE;
@@
-53,7
+53,7
@@
int parse_arguments(char **argv)
const char *buffer_usage_threshold_type = NULL;
const char *buffer_usage_threshold_value = NULL;
const char *nr_expected_notifications_string = NULL;
const char *buffer_usage_threshold_type = NULL;
const char *buffer_usage_threshold_value = NULL;
const char *nr_expected_notifications_string = NULL;
- const char *use_action_
group
_value = NULL;
+ const char *use_action_
list
_value = NULL;
session_name = argv[1];
channel_name = argv[2];
session_name = argv[1];
channel_name = argv[2];
@@
-62,7
+62,7
@@
int parse_arguments(char **argv)
buffer_usage_threshold_type = argv[5];
buffer_usage_threshold_value = argv[6];
nr_expected_notifications_string = argv[7];
buffer_usage_threshold_type = argv[5];
buffer_usage_threshold_value = argv[6];
nr_expected_notifications_string = argv[7];
- use_action_
group
_value = argv[8];
+ use_action_
list
_value = argv[8];
/* Parse arguments */
/* Domain type */
/* Parse arguments */
/* Domain type */
@@
-92,12
+92,24
@@
int parse_arguments(char **argv)
/* Ratio or bytes ? */
if (!strcasecmp("bytes", buffer_usage_threshold_type)) {
is_threshold_ratio = false;
/* Ratio or bytes ? */
if (!strcasecmp("bytes", buffer_usage_threshold_type)) {
is_threshold_ratio = false;
- sscanf(buffer_usage_threshold_value, "%" SCNu64, &threshold_bytes);
+ sscanf_ret = sscanf(buffer_usage_threshold_value, "%" SCNu64,
+ &threshold_bytes);
+ if (sscanf_ret != 1) {
+ printf("error: Invalid buffer usage threshold value bytes (integer), sscanf returned %d\n",
+ sscanf_ret);
+ goto error;
+ }
}
if (!strcasecmp("ratio", buffer_usage_threshold_type)) {
is_threshold_ratio = true;
}
if (!strcasecmp("ratio", buffer_usage_threshold_type)) {
is_threshold_ratio = true;
- sscanf(buffer_usage_threshold_value, "%lf", &threshold_ratio);
+ sscanf_ret = sscanf(buffer_usage_threshold_value, "%lf",
+ &threshold_ratio);
+ if (sscanf_ret != 1) {
+ printf("error: Invalid buffer usage threshold value ratio (float), sscanf returned %d\n",
+ sscanf_ret);
+ goto error;
+ }
}
/* Number of notification to expect */
}
/* Number of notification to expect */
@@
-110,8
+122,8
@@
int parse_arguments(char **argv)
}
/* Put notify action in a group. */
}
/* Put notify action in a group. */
- if (!strcasecmp("1", use_action_
group
_value)) {
- use_action_
group
= true;
+ if (!strcasecmp("1", use_action_
list
_value)) {
+ use_action_
list
= true;
}
return 0;
}
return 0;
@@
-129,6
+141,7
@@
int main(int argc, char **argv)
struct lttng_condition *condition = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
struct lttng_condition *condition = NULL;
struct lttng_action *action = NULL;
struct lttng_trigger *trigger = NULL;
+ enum lttng_error_code ret_code;
/*
* Disable buffering on stdout.
/*
* Disable buffering on stdout.
@@
-213,12
+226,12
@@
int main(int argc, char **argv)
goto end;
}
goto end;
}
- if (use_action_
group
) {
+ if (use_action_
list
) {
struct lttng_action *notify, *group;
struct lttng_action *notify, *group;
- group = lttng_action_
group
_create();
+ group = lttng_action_
list
_create();
if (!group) {
if (!group) {
- printf("error: Could not create action
group
\n");
+ printf("error: Could not create action
list
\n");
ret = 1;
goto end;
}
ret = 1;
goto end;
}
@@
-231,9
+244,9
@@
int main(int argc, char **argv)
goto end;
}
goto end;
}
- action_status = lttng_action_
group
_add_action(group, notify);
+ action_status = lttng_action_
list
_add_action(group, notify);
if (action_status != LTTNG_ACTION_STATUS_OK) {
if (action_status != LTTNG_ACTION_STATUS_OK) {
- printf("error: Could not add action notify to action
group
\n");
+ printf("error: Could not add action notify to action
list
\n");
lttng_action_destroy(group);
lttng_action_destroy(notify);
ret = 1;
lttng_action_destroy(group);
lttng_action_destroy(notify);
ret = 1;
@@
-257,14
+270,14
@@
int main(int argc, char **argv)
goto end;
}
goto end;
}
- ret
= lttng_register_trigger
(trigger);
+ ret
_code = lttng_register_trigger_with_automatic_name
(trigger);
/*
* An equivalent trigger might already be registered if an other app
* registered an equivalent trigger.
*/
/*
* An equivalent trigger might already be registered if an other app
* registered an equivalent trigger.
*/
- if (ret
< 0 && ret != -
LTTNG_ERR_TRIGGER_EXISTS) {
- printf("error: %s\n", lttng_strerror(
ret
));
+ if (ret
_code != LTTNG_OK && ret_code !=
LTTNG_ERR_TRIGGER_EXISTS) {
+ printf("error: %s\n", lttng_strerror(
-ret_code
));
ret = 1;
goto end;
}
ret = 1;
goto end;
}
This page took
0.025762 seconds
and
4
git commands to generate.