VirtualBox

Ignore:
Timestamp:
Aug 10, 2016 3:01:05 PM (8 years ago)
Author:
vboxsync
Message:

NetworkServices: warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp

    r63274 r63284  
    5252
    5353
    54 static int netPfStrAddressParse(char *pszRaw, size_t cbRaw,
     54static int netPfStrAddressParse(char *pszRaw, size_t cchRaw,
    5555                                char *pszAddress, int cbAddress,
    5656                                bool fEmptyAcceptable)
    5757{
    58     int cbField = 0;
     58    size_t cchField = 0;
    5959
    6060    AssertPtrReturn(pszRaw, -1);
     
    6666        /* shift pszRaw to next symbol */
    6767        pszRaw++;
    68         cbRaw--;
     68        cchRaw--;
    6969
    7070
    7171        /* we shouldn't face with ending here */
    72         AssertReturn(cbRaw > 0, VERR_INVALID_PARAMETER);
     72        AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER);
    7373
    7474        char *pszEndOfAddress = RTStrStr(pszRaw, PF_STR_ADDRESS_FIELD_ENDS);
     
    7777        AssertPtrReturn(pszEndOfAddress, VERR_INVALID_PARAMETER);
    7878
    79         cbField = pszEndOfAddress - pszRaw;
     79        cchField = pszEndOfAddress - pszRaw;
    8080
    8181        /* field should be less then the rest of the string */
    82         AssertReturn(cbField < cbRaw, VERR_INVALID_PARAMETER);
    83 
    84         if (cbField != 0)
    85             RTStrCopy(pszAddress, RT_MIN(cbField + 1, cbAddress), pszRaw);
     82        AssertReturn(cchField < cchRaw, VERR_INVALID_PARAMETER);
     83
     84        if (cchField != 0)
     85            RTStrCopy(pszAddress, RT_MIN(cchField + 1, cbAddress), pszRaw);
    8686        else if (!fEmptyAcceptable)
    8787            return -1;
    8888    }
    8989
    90     AssertReturn(pszRaw[cbField] == PF_ADDRESS_FIELD_ENDS, -1);
    91 
    92     return cbField + 2; /* length of the field and closing braces */
     90    AssertReturn(pszRaw[cchField] == PF_ADDRESS_FIELD_ENDS, -1);
     91
     92    return (int)cchField + 2; /* length of the field and closing braces */
    9393}
    9494
     
    134134
    135135    pszRaw++; /* skip field separator */
    136     cbRaw --;
     136    cchRaw --;
    137137
    138138    char *pszEndOfPort = RTStrStr(pszRaw, ":");
     
    141141        cbRest = strlen(pszRaw);
    142142
    143         Assert(cbRaw == cbRest);
     143        Assert(cchRaw == cbRest);
    144144
    145145        /* XXX: Assumption that if string is too big, it will be reported by
     
    178178
    179179
    180 static int netPfStrAddressPortPairParse(char *pszRaw, size_t cbRaw,
     180static int netPfStrAddressPortPairParse(char *pszRaw, size_t cchRaw,
    181181                                        char *pszAddress, int cbAddress,
    182182                                        bool fEmptyAddressAcceptable,
     
    195195
    196196    pszRaw++; /* field separator skip */
    197     cbRaw--;
    198     AssertReturn(cbRaw > 0, VERR_INVALID_PARAMETER);
     197    cchRaw--;
     198    AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER);
    199199
    200200    idxRaw = 0;
     
    203203    {
    204204        idxRaw += netPfStrAddressParse(pszRaw,
    205                                        cbRaw - idxRaw,
     205                                       cchRaw - idxRaw,
    206206                                       pszAddress,
    207207                                       cbAddress,
     
    216216    pszRaw += idxRaw;
    217217    idxRawTotal += idxRaw;
    218     cbRaw -= idxRaw;
    219 
    220     AssertReturn(cbRaw > 0, VERR_INVALID_PARAMETER);
     218    cchRaw -= idxRaw;
     219
     220    AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER);
    221221
    222222    idxRaw = 0;
     
    265265    char *pszName = &pPfr->szPfrName[0];
    266266
    267     size_t cbRaw = strlen(pcszStrPortForward);
     267    size_t cchRaw = strlen(pcszStrPortForward);
    268268
    269269    /* Minimal rule ":tcp:[]:0:[]:0" has got lenght 14 */
    270     AssertReturn(cbRaw > 14, VERR_INVALID_PARAMETER);
     270    AssertReturn(cchRaw > 14, VERR_INVALID_PARAMETER);
    271271
    272272    char *pszRaw = RTStrDup(pcszStrPortForward);
     
    286286        cbToken = pszEndOfName - pszRaw; /* don't take : into account */
    287287        /* XXX it's unacceptable to have only name entry in PF */
    288         AssertReturn(cbToken < cbRaw, VERR_INVALID_PARAMETER);
     288        AssertReturn(cbToken < cchRaw, VERR_INVALID_PARAMETER);
    289289
    290290        if (   cbToken < 0
     
    296296                  pszRaw);
    297297        pszRaw += cbToken; /* move to separator */
    298         cbRaw -= cbToken;
     298        cchRaw -= cbToken;
    299299    }
    300300
     
    303303
    304304    pszRaw++; /* skip separator */
    305     cbRaw--;
     305    cchRaw--;
    306306    idxRaw = 0;
    307307
     
    317317
    318318    pszRaw += idxRaw;
    319     cbRaw -= idxRaw;
    320 
    321     idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw,
     319    cchRaw -= idxRaw;
     320
     321    idxRaw = netPfStrAddressPortPairParse(pszRaw, cchRaw,
    322322                                          pszHostAddr, INET6_ADDRSTRLEN,
    323323                                          true, &u16HostPort);
     
    326326
    327327    pszRaw += idxRaw;
    328     cbRaw -= idxRaw;
     328    cchRaw -= idxRaw;
    329329
    330330    Assert(pszRaw[0] == PF_FIELD_SEPARATOR);
    331331
    332     idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw,
     332    idxRaw = netPfStrAddressPortPairParse(pszRaw, cchRaw,
    333333                                          pszGuestAddr, INET6_ADDRSTRLEN,
    334334                                          false, &u16GuestPort);
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