Skip to content

Commit

Permalink
in_calyptia_fleet: check return value from strtol.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Sep 15, 2023
1 parent 9364536 commit 8650aa7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ static int is_timestamped_fleet_config(struct flb_in_calyptia_fleet_config *ctx,
{
char *fname;
char *end;
long val;

if (cfg->conf_path_file == NULL) {
return FLB_FALSE;
Expand All @@ -278,7 +279,15 @@ static int is_timestamped_fleet_config(struct flb_in_calyptia_fleet_config *ctx,
}

fname++;
(void)strtol(fname, &end, 10);

errno = 0;
val = strtol(fname, &end, 10);

if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) ||
(errno != 0 && val == 0)) {
flb_errno();
return FLB_FALSE;
}

if (strcmp(end, ".ini") == 0) {
return FLB_TRUE;
Expand Down Expand Up @@ -991,8 +1000,15 @@ static int load_fleet_config(struct flb_in_calyptia_fleet_config *ctx)
return FLB_FALSE;
}

errno = 0;
timestamp = strtol(fname, &ext, 10);

if ((errno == ERANGE && (timestamp == LONG_MAX || timestamp == LONG_MIN)) ||
(errno != 0 && timestamp == 0)) {
flb_errno();
return FLB_FALSE;
}

/* unable to parse the timstamp */
if (errno == ERANGE) {
return FLB_FALSE;
Expand Down

0 comments on commit 8650aa7

Please sign in to comment.