VirtualBox

vbox的更動 63274 路徑 trunk/src/VBox/NetworkServices


忽略:
時間撮記:
2016-8-10 下午02:17:15 (8 年 以前)
作者:
vboxsync
訊息:

VBoxNetPortForwardString.cpp: Kicked the code into being warning free (still ugly)

位置:
trunk/src/VBox/NetworkServices
檔案:
修改 3 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp

    r63267 r63274  
    13411341        RT_ZERO(Rule);
    13421342
    1343         int rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(),
    1344                               fIsIPv6, &Rule.Pfr);
     1343        int rc = netPfStrToPf(com::Utf8Str(rules[idxRules]).c_str(), fIsIPv6,
     1344                              &Rule.Pfr);
    13451345        if (RT_FAILURE(rc))
    13461346            continue;
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp

    r63272 r63274  
    5151#define PF_STR_ADDRESS_FIELD_ENDS "]"
    5252
    53 static int netPfStrAddressParse(char *pszRaw, int cbRaw,
     53
     54static int netPfStrAddressParse(char *pszRaw, size_t cbRaw,
    5455                                char *pszAddress, int cbAddress,
    5556                                bool fEmptyAcceptable)
     
    100101 * @param   pszRaw          The zero terminated string to parse.  Points a field
    101102 *                          separator.
    102  * @param   cbRaw           Number of valid bytes in the buffer @a pszRaw points
    103  *                          at.  (Ignored since pszRaw is terminated.)
    104103 * @param   pu16Port        Where to store the port number on success.
    105104 */
    106 static int netPfStrPortParse(char *pszRaw, int cbRaw, uint16_t *pu16Port)
     105static int netPfStrPortParse(char *pszRaw, uint16_t *pu16Port)
    107106{
    108107#if 1
     
    121120    if (*pu16Port == 0)
    122121        return -1;
    123     Assert((uinpttr_t)pszNext <= (uintptr_t)&pszRaw[cbRaw]); NOREF(cbRaw);
    124122    return (int)(pszNext - pszRaw);
    125123
     
    180178
    181179
    182 static int netPfStrAddressPortPairParse(char *pszRaw, int cbRaw,
     180static int netPfStrAddressPortPairParse(char *pszRaw, size_t cbRaw,
    183181                                        char *pszAddress, int cbAddress,
    184182                                        bool fEmptyAddressAcceptable,
     
    228226    if (pszRaw[0] == PF_FIELD_SEPARATOR)
    229227    {
    230         idxRaw = netPfStrPortParse(pszRaw, strlen(pszRaw), pu16Port);
     228        idxRaw = netPfStrPortParse(pszRaw, pu16Port);
    231229
    232230        Assert(strlen(&pszRaw[idxRaw]) == 0 || pszRaw[idxRaw] == PF_FIELD_SEPARATOR);
     
    244242/* XXX: Having fIPv6 we might emprove adress verification comparing address length
    245243 * with INET[6]_ADDRLEN
     244 *
    246245 */
    247 int netPfStrToPf(const char *pcszStrPortForward, int fIPv6, PPORTFORWARDRULE pPfr)
     246int netPfStrToPf(const char *pcszStrPortForward, bool fIPv6, PPORTFORWARDRULE pPfr)
    248247{
    249     char *pszName;
     248/** r=bird: Redo from scratch?  This is very hard to read. */
     249
    250250    int  proto;
    251     char *pszHostAddr;
    252     char *pszGuestAddr;
    253251    uint16_t u16HostPort;
    254252    uint16_t u16GuestPort;
    255253    bool fTcpProto = false;
    256254
    257     char *pszRawBegin = NULL;
    258     char *pszRaw = NULL;
    259255    int idxRaw = 0;
    260256    int cbToken = 0;
    261     int cbRaw = 0;
    262     int rc = VINF_SUCCESS;
    263257
    264258    AssertPtrReturn(pcszStrPortForward, VERR_INVALID_PARAMETER);
     
    267261    RT_ZERO(*pPfr);
    268262
    269     pszHostAddr = &pPfr->szPfrHostAddr[0];
    270     pszGuestAddr = &pPfr->szPfrGuestAddr[0];
    271     pszName = &pPfr->szPfrName[0];
    272 
    273     cbRaw = strlen(pcszStrPortForward);
     263    char *pszHostAddr = &pPfr->szPfrHostAddr[0];
     264    char *pszGuestAddr = &pPfr->szPfrGuestAddr[0];
     265    char *pszName = &pPfr->szPfrName[0];
     266
     267    size_t cbRaw = strlen(pcszStrPortForward);
    274268
    275269    /* Minimal rule ":tcp:[]:0:[]:0" has got lenght 14 */
    276270    AssertReturn(cbRaw > 14, VERR_INVALID_PARAMETER);
    277271
    278     pszRaw = RTStrDup(pcszStrPortForward);
     272    char *pszRaw = RTStrDup(pcszStrPortForward);
    279273    AssertReturn(pszRaw, VERR_NO_MEMORY);
    280274
    281     pszRawBegin = pszRaw;
     275    char *pszRawBegin = pszRaw;
    282276
    283277    /* name */
     
    290284            goto invalid_parameter;
    291285
    292         cbToken = (pszEndOfName) - pszRaw; /* don't take : into account */
     286        cbToken = pszEndOfName - pszRaw; /* don't take : into account */
    293287        /* XXX it's unacceptable to have only name entry in PF */
    294288        AssertReturn(cbToken < cbRaw, VERR_INVALID_PARAMETER);
     
    326320
    327321    idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw,
    328                                          pszHostAddr, INET6_ADDRSTRLEN,
    329                                          true, &u16HostPort);
     322                                          pszHostAddr, INET6_ADDRSTRLEN,
     323                                          true, &u16HostPort);
    330324    if (idxRaw < 0)
    331325        return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/NetworkServices/NetLib/VBoxPortForwardString.h

    r62481 r63274  
    4949} PORTFORWARDRULE, *PPORTFORWARDRULE;
    5050
    51 int netPfStrToPf(const char *pcszStrPortForward,int fIPv6, PPORTFORWARDRULE pPfr);
     51int netPfStrToPf(const char *pszStrPortForward, bool fIPv6, PPORTFORWARDRULE pPfr);
    5252
    5353RT_C_DECLS_END
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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