mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Skip trailing whitespaces when parsing integer options
strtoint(), via strtol(), would skip leading whitespaces but the same rule was not applied for trailing whitespaces, leading to an inconsistent behavior. Some tests are changed to cover more this area. Author: Michael Paquier Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/YP5Pv0d13Ct+03ve@paquier.xyz
This commit is contained in:
@ -57,7 +57,14 @@ option_parse_int(const char *optarg, const char *optname,
|
||||
errno = 0;
|
||||
val = strtoint(optarg, &endptr, 10);
|
||||
|
||||
if (*endptr)
|
||||
/*
|
||||
* Skip any trailing whitespace; if anything but whitespace remains before
|
||||
* the terminating character, fail.
|
||||
*/
|
||||
while (*endptr != '\0' && isspace((unsigned char) *endptr))
|
||||
endptr++;
|
||||
|
||||
if (*endptr != '\0')
|
||||
{
|
||||
pg_log_error("invalid value \"%s\" for option %s",
|
||||
optarg, optname);
|
||||
|
Reference in New Issue
Block a user