Skip to content

Commit

Permalink
[#306] Remove atoi() in as_logging_level()
Browse files Browse the repository at this point in the history
Use the internal function `as_int()` that checks for overflows and not
parsable strings.

Close #306
  • Loading branch information
fluca1978 committed Aug 12, 2022
1 parent 1296cc4 commit 9c02f0f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libpgagroal/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,11 @@ as_logging_level(char* str)
debug_value = (char*)malloc(size + 1);
memset(debug_value, 0, size + 1);
memcpy(debug_value, str + 5, size);
debug_level = atoi(debug_value);
if (as_int(debug_value, &debug_level))
{
// cannot parse, set it to 1
debug_level = 1;
}
free(debug_value);
}

Expand Down

0 comments on commit 9c02f0f

Please sign in to comment.