Skip to content

Commit

Permalink
in_node_exporter_metrics: check return code for flb_sds_cat_safe.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Aug 7, 2023
1 parent 2719499 commit e945bd1
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions plugins/in_node_exporter_metrics/ne_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,33 @@ int ne_utils_file_read_uint64(const char *mount,
}

len = strlen(path);
flb_sds_cat_safe(&p, path, len);
if (flb_sds_cat_safe(&p, path, len) < 0) {
flb_sds_destroy(p);
return -1;
}

if (join_a) {
flb_sds_cat_safe(&p, "/", 1);
if (flb_sds_cat_safe(&p, "/", 1) < 0) {
flb_sds_destroy(p);
return -1;
}
len = strlen(join_a);
flb_sds_cat_safe(&p, join_a, len);
if (flb_sds_cat_safe(&p, join_a, len) < 0) {
flb_sds_destroy(p);
return -1;
}
}

if (join_b) {
flb_sds_cat_safe(&p, "/", 1);
if (flb_sds_cat_safe(&p, "/", 1) < 0) {
flb_sds_destroy(p);
return -1;
}
len = strlen(join_b);
flb_sds_cat_safe(&p, join_b, len);
if (flb_sds_cat_safe(&p, join_b, len) < 0) {
flb_sds_destroy(p);
return -1;
}
}

fd = open(p, O_RDONLY);
Expand Down

0 comments on commit e945bd1

Please sign in to comment.