From 62d69e190972f2669fdfc12ef93b7f8983c726d8 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Fri, 10 May 2013 13:46:58 -0400 Subject: [PATCH] Lists of IPs should be comma-separated rather than semicolon or space-separated. --- ifchd/ifchd.c | 4 ++-- ndhc/ifchange.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ifchd/ifchd.c b/ifchd/ifchd.c index 6d644de..7cf8ae1 100644 --- a/ifchd/ifchd.c +++ b/ifchd/ifchd.c @@ -182,7 +182,7 @@ static void write_resolve_conf(struct ifchd_client *cl) char *p = cl->namesvrs; while (p && (*p != '\0')) { - char *q = strchr(p, ' '); + char *q = strchr(p, ','); if (!q) q = strchr(p, '\0'); else @@ -199,7 +199,7 @@ static void write_resolve_conf(struct ifchd_client *cl) p = cl->domains; int numdoms = 0; while (p && (*p != '\0')) { - char *q = strchr(p, ' '); + char *q = strchr(p, ','); if (!q) q = strchr(p, '\0'); else diff --git a/ndhc/ifchange.c b/ndhc/ifchange.c index 477d246..1fa7ca3 100644 --- a/ndhc/ifchange.c +++ b/ndhc/ifchange.c @@ -97,9 +97,10 @@ static int ifchd_cmd_iplist(char *buf, size_t buflen, char *optname, { char ipbuf[INET_ADDRSTRLEN]; char *obuf = buf; - if (!optdata) + if (!optdata || optlen < 4) return -1; - ssize_t wc = ifchd_cmd_ip(buf, buflen, optname, optdata, optlen); + inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf); + ssize_t wc = snprintf(buf, buflen, "%s:%s", optname, ipbuf); if (wc <= 0) return wc; optlen -= 4; @@ -109,13 +110,11 @@ static int ifchd_cmd_iplist(char *buf, size_t buflen, char *optname, inet_ntop(AF_INET, optdata, ipbuf, sizeof ipbuf); if (buflen < strlen(ipbuf) + (buf - obuf) + 2) break; - if (optlen >= 8) - buf += snprintf(buf, buflen - (buf - obuf), "%s:", ipbuf); - else - buf += snprintf(buf, buflen - (buf - obuf), "%s;", ipbuf); + buf += snprintf(buf, buflen - (buf - obuf), ",%s", ipbuf); optlen -= 4; optdata += 4; } + buf += snprintf(buf, buflen - (buf - obuf), ";"); return buf - obuf; }