Skip to content

Commit

Permalink
tools/nut-scanner/nutscan-ip.c: nutscan_cidr_to_ip(): strip square br…
Browse files Browse the repository at this point in the history
…ackets around first_ip, if any [networkupstools#2512]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 8, 2024
1 parent 2dc471f commit 18e9be0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/nut-scanner/nutscan-ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,18 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip)
if (mask == NULL) {
upsdebugx(0, "WARNING: %s failed to parse mask from cidr=%s (first_ip=%s)",
__func__, cidr, first_ip);
free (first_ip);
free(first_ip);
free(cidr_tok);
return 0;
}

if (first_ip[0] == '[' && first_ip[strlen(first_ip) - 1] == ']') {
char *s = strdup(first_ip + 1);
s[strlen(s) - 1] = '\0';
free(first_ip);
first_ip = s;
}

upsdebugx(5, "%s: parsed cidr=%s into first_ip=%s and mask=%s",
__func__, cidr, first_ip, mask);

Expand Down

0 comments on commit 18e9be0

Please sign in to comment.