Skip to content

Commit

Permalink
clients/upsclient.c: troubleshoot wrong upsname@hostname where only h…
Browse files Browse the repository at this point in the history
…ostname was expected [networkupstools#2512]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 8, 2024
1 parent 8538657 commit b60d4c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,16 @@ int upscli_splitaddr(const char *buf, char **hostname, uint16_t *port)
return -1;
}

s = strchr(tmp, '@');

/* someone passed a "@hostname" string? */
if (s) {
fprintf(stderr, "upscli_splitaddr: wrong call? "
"Got upsname@hostname[:port] string where "
"only hostname[:port] was expected: %s\n", buf);
/* let it pass, but probably fail later */
}

if (*tmp == '[') {
if (strchr(tmp, ']') == NULL) {
fprintf(stderr, "upscli_splitaddr: missing closing bracket in [domain literal]\n");
Expand Down

0 comments on commit b60d4c0

Please sign in to comment.