VirtualBox

Ignore:
Timestamp:
Sep 21, 2016 1:06:12 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110804
Message:

NAT: strip comment before processing resolv.conf line to simplify
things a bit.

Note: This is not how ad-hoc parser in bind's res_init.c does it, btw,
so this code will accept more input as valid compared to res_init.
E.g. "nameserver 1.1.1.1; comment" is misparsed by res_init.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/resolv_conf_parser.c

    r63913 r63921  
    157157        }
    158158
     159        /*
     160         * Strip comment if present.
     161         *
     162         * This is not how ad-hoc parser in bind's res_init.c does it,
     163         * btw, so this code will accept more input as valid compared
     164         * to res_init.  (e.g. "nameserver 1.1.1.1; comment" is
     165         * misparsed by res_init).
     166         */
     167        for (s = buf; *s != '\0'; ++s)
     168        {
     169            if (*s == '#' || *s == ';')
     170            {
     171                *s = '\0';
     172                break;
     173            }
     174        }
    159175
    160176        tok = getToken(buf, &s);
    161 
    162         /* no more tokens or a comment */
    163 #       define NO_VALUE(tok)  (tok == NULL || tok[0] == '#' || tok[0] == ';')
    164 
    165         if (NO_VALUE(tok))
     177        if (tok == NULL)
    166178            continue;
    167179
     
    194206             */
    195207            tok = getToken(NULL, &s);
    196             if (NO_VALUE(tok))
     208            if (tok == NULL)
    197209            {
    198210                LogRel(("NAT: resolv.conf: nameserver line without value\n"));
     
    252264
    253265            tok = getToken(NULL, &s);
    254             if (!NO_VALUE(tok))
     266            if (tok != NULL)
    255267                LogRel(("NAT: resolv.conf: ignoring unexpected trailer on the nameserver line\n"));
    256268
     
    304316
    305317            tok = getToken(NULL, &s);
    306             if (NO_VALUE(tok))
     318            if (tok == NULL)
    307319            {
    308320                LogRel(("NAT: resolv.conf: port line without value\n"));
     
    336348
    337349            tok = getToken(NULL, &s);
    338             if (NO_VALUE(tok))
     350            if (tok == NULL)
    339351            {
    340352                LogRel(("NAT: resolv.conf: domain line without value\n"));
     
    362374        if (RTStrCmp(tok, "search") == 0)
    363375        {
    364             while ((tok = getToken(NULL, &s)) && !NO_VALUE(tok))
     376            while ((tok = getToken(NULL, &s)) && tok != NULL)
    365377            {
    366378                i = state->rcps_num_searchlist;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette