[PATCH rhel6-branch] Support multiple nameservers in loader TUI (#795535)

Brian C. Lane bcl at redhat.com
Tue Sep 25 17:47:20 UTC 2012


On Tue, Sep 25, 2012 at 11:08:42AM +0200, Radek Vykydal wrote:
> Comma separated as in kickstart and boot options.
> 
> Resolves: rhbz#795535
> ---
>  loader/net.c |   98 +++++++++++++++++++++++++++++----------------------------
>  loader/net.h |    2 +-
>  2 files changed, 51 insertions(+), 49 deletions(-)


> +    /* Scan the dns parameter for multiple comma-separated IP addresses */
> +    c = strtok(buf, ",");
> +    while ((iface->numdns < MAXNS) && (c != NULL)) {
> +        if (inet_pton(AF_INET, c, &addr) >= 1) {
> +            iface->dns[iface->numdns] = strdup(c);
> +            iface->numdns++;
> +
> +            if (inet_ntop(AF_INET, &addr, ret, INET_ADDRSTRLEN) == NULL) {
> +                logMessage(ERROR, "%s (%d): %s", __func__, __LINE__, strerror(errno));
> +            } else {
> +                logMessage(DEBUGLVL, "adding dns4 %s", ret);
> +                c = strtok(NULL, ",");
> +            }
> +        } else if (inet_pton(AF_INET6, c, &addr6) >= 1) {
> +            iface->dns[iface->numdns] = strdup(c);
> +            iface->numdns++;
> +
> +            if (inet_ntop(AF_INET6, &addr6, ret, INET6_ADDRSTRLEN) == NULL) {
> +                logMessage(ERROR, "%s (%d): %s", __func__, __LINE__, strerror(errno));
> +            } else {
> +                logMessage(DEBUGLVL, "adding dns6 %s", ret);
> +                c = strtok(NULL, ",");
> +            }
> +        }
> +    }
> +}

I think the c = strtok(NULL, ","); needs to be moved to the bottom of
the while loop, otherwise on an error it is going to fill it up with the
bad dns entries. It also shouldn't be filling in ->dns and advancing
numdns until it passes inet_ntop. I know this was cut-and-pasted from
the old code, but it isn't handling the error case correctly.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20120925/211f80af/attachment.sig>


More information about the anaconda-patches mailing list