VirtualBox

Changeset 50670 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Mar 4, 2014 1:00:02 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92608
Message:

NAT: resolv_conf_parser.c:
1.search lists can be in numeric format, e.g.

search beadbabe 123cafe

are valid names

  1. droped limitation of single search per resolv.conf search 1cafe search 2cafe

is acceptable format.

  1. reduced grade of error: too many "search" items or invalid search entries are ignored instead of ignoring whole file.
File:
1 edited

Legend:

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

    r50150 r50670  
    2929#include "resolv_conf_parser.h"
    3030
     31/* XXX: it's required to add the aliases for keywords and
     32 * types to handle conditions more clearly */
    3133enum RCP_TOKEN
    3234{
     
    3840  tok_ipv6 = -6, /* ipv6 */
    3941  tok_ipv6_port = -7, /* ipv6 port */
     42  /* keywords */
    4043  tok_nameserver = -8, /* nameserver */
    4144  tok_port = -9, /* port, Mac OSX specific */
     
    382385 * @note: resolv.conf (5) Linux:
    383386 * "The search list is currently limited to six domains with a total of 256 characters."
     387 * @note: 'search' parameter could contains numbers only hex or decimal, 1c1e or 111
    384388 */
    385389static enum RCP_TOKEN rcp_parse_search(struct rcp_parser *parser)
     
    393397    st = parser->rcpp_state;
    394398
    395     /**
    396      * We asume that duplication of search list in resolv.conf isn't correct.
    397      */
    398399    if (   tok == tok_eof
    399         || tok == tok_error
    400         || tok != tok_string
    401         || st->rcps_searchlist[0] != NULL)
     400        || tok == tok_error)
    402401        return tok_error;
    403402
    404     i = 0;
    405     trailing = RCPS_BUFFER_SIZE;
    406     do {
     403    /* just ignore "too many search list" */
     404    if (st->rcps_num_searchlist >= RCPS_MAX_SEARCHLIST)
     405        return rcp_get_token(parser);
     406   
     407    /* we don't want accept keywords */
     408    if (tok <= tok_nameserver)
     409        return tok;
     410
     411    /* if there're several entries of "search" we compose them together */
     412    i = st->rcps_num_searchlist;
     413    if ( i == 0)
     414        trailing = RCPS_BUFFER_SIZE;
     415    else
     416    {
     417        ptr = st->rcps_searchlist[i - 1];
     418        trailing = RCPS_BUFFER_SIZE - (ptr -
     419                                       st->rcps_searchlist_buffer + strlen(ptr) + 1);
     420    }
     421
     422    while (1)
     423    {
    407424        len = strlen(parser->rcpp_str_buffer);
    408425
     
    410427            break; /* not enough room for new entry */
    411428
     429        if (i >= RCPS_MAX_SEARCHLIST)
     430            break; /* not enought free entries for 'search' items */
     431
    412432        ptr = st->rcps_searchlist_buffer + RCPS_BUFFER_SIZE - trailing;
    413433        strcpy(ptr, parser->rcpp_str_buffer);
     
    415435        trailing -= len + 1; /* 1 reserved for '\0' */
    416436
    417         st->rcps_searchlist[i] = ptr;
    418 
    419     } while(  (tok = rcp_get_token(parser)) == tok_string
    420             && ++i != RCPS_MAX_SEARCHLIST);
     437        st->rcps_searchlist[i++] = ptr;
     438        tok = rcp_get_token(parser);
     439
     440        /* token filter */
     441        if (   tok == tok_eof
     442            || tok == tok_error
     443            || tok <= tok_nameserver)
     444            break;
     445    }
    421446
    422447    st->rcps_num_searchlist = i;
Note: See TracChangeset for help on using the changeset viewer.

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