Skip to content

Commit

Permalink
Problem: isdigit() receives a char* instead of char
Browse files Browse the repository at this point in the history
Solution: as a quick fix, pick the first char of the string we pass.
The proper fix would be to use the str_*() API for safe conversions,
in a later iteration.

See-also: networkupstools#676

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Apr 5, 2019
1 parent 28c2306 commit 04da795
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static int parse_upsd_conf_args(int numargs, char **arg)

/* MAXAGE <seconds> */
if (!strcmp(arg[0], "MAXAGE")) {
if (isdigit(arg[1])) {
if (isdigit(arg[1][0])) {
maxage = atoi(arg[1]);
return 1;
}
Expand All @@ -134,7 +134,7 @@ static int parse_upsd_conf_args(int numargs, char **arg)

/* TRACKINGDELAY <seconds> */
if (!strcmp(arg[0], "TRACKINGDELAY")) {
if (isdigit(arg[1])) {
if (isdigit(arg[1][0])) {
tracking_delay = atoi(arg[1]);
return 1;
}
Expand All @@ -146,7 +146,7 @@ static int parse_upsd_conf_args(int numargs, char **arg)

/* MAXCONN <connections> */
if (!strcmp(arg[0], "MAXCONN")) {
if (isdigit(arg[1])) {
if (isdigit(arg[1][0])) {
maxconn = atoi(arg[1]);
return 1;
}
Expand Down Expand Up @@ -187,7 +187,7 @@ static int parse_upsd_conf_args(int numargs, char **arg)
#ifdef WITH_CLIENT_CERTIFICATE_VALIDATION
/* CERTREQUEST (0 | 1 | 2) */
if (!strcmp(arg[0], "CERTREQUEST")) {
if (isdigit(arg[1])) {
if (isdigit(arg[1][0])) {
certrequest = atoi(arg[1]);
return 1;
}
Expand Down

0 comments on commit 04da795

Please sign in to comment.