VirtualBox

Changeset 103448 in vbox for trunk/src/VBox/NetworkServices


Ignore:
Timestamp:
Feb 19, 2024 2:20:41 PM (9 months ago)
Author:
vboxsync
Message:

NetworkServices/NetLib/VBoxNetPortForwardString.cpp: Fix some parfait warnings, bugref:3409

File:
1 edited

Legend:

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

    r98103 r103448  
    7575    AssertReturn(pszRaw[0] == PF_ADDRESS_FIELD_STARTS, -1);
    7676
    77     if (pszRaw[0] == PF_ADDRESS_FIELD_STARTS)
    78     {
    79         /* shift pszRaw to next symbol */
    80         pszRaw++;
    81         cchRaw--;
    82 
    83 
    84         /* we shouldn't face with ending here */
    85         AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER);
    86 
    87         char *pszEndOfAddress = RTStrStr(pszRaw, PF_STR_ADDRESS_FIELD_ENDS);
    88 
    89         /* no pair closing sign */
    90         AssertPtrReturn(pszEndOfAddress, VERR_INVALID_PARAMETER);
    91 
    92         cchField = pszEndOfAddress - pszRaw;
    93 
    94         /* field should be less then the rest of the string */
    95         AssertReturn(cchField < cchRaw, VERR_INVALID_PARAMETER);
    96 
    97         if (cchField != 0)
    98             RTStrCopy(pszAddress, RT_MIN(cchField + 1, (size_t)cbAddress), pszRaw);
    99         else if (!fEmptyAcceptable)
    100             return -1;
    101     }
     77    /* shift pszRaw to next symbol */
     78    pszRaw++;
     79    cchRaw--;
     80
     81    /* we shouldn't face with ending here */
     82    AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER);
     83
     84    char *pszEndOfAddress = RTStrStr(pszRaw, PF_STR_ADDRESS_FIELD_ENDS);
     85
     86    /* no pair closing sign */
     87    AssertPtrReturn(pszEndOfAddress, VERR_INVALID_PARAMETER);
     88
     89    cchField = pszEndOfAddress - pszRaw;
     90
     91    /* field should be less then the rest of the string */
     92    AssertReturn(cchField < cchRaw, VERR_INVALID_PARAMETER);
     93
     94    if (cchField != 0)
     95        RTStrCopy(pszAddress, RT_MIN(cchField + 1, (size_t)cbAddress), pszRaw);
     96    else if (!fEmptyAcceptable)
     97        return -1;
    10298
    10399    AssertReturn(pszRaw[cchField] == PF_ADDRESS_FIELD_ENDS, -1);
    104 
    105100    return (int)cchField + 2; /* length of the field and closing braces */
    106101}
     
    290285
    291286    /* name */
    292     if (pszRaw[idxRaw] == PF_FIELD_SEPARATOR)
    293         idxRaw = 1; /* begin of the next segment */
    294     else
     287    if (pszRaw[idxRaw] != PF_FIELD_SEPARATOR)
    295288    {
    296289        char *pszEndOfName = RTStrStr(pszRaw + 1, PF_STR_FIELD_SEPARATOR);
     
    377370invalid_parameter:
    378371    RTStrFree(pszRawBegin);
    379     if (pPfr)
    380         RT_ZERO(*pPfr);
     372    RT_ZERO(*pPfr);
    381373    return VERR_INVALID_PARAMETER;
    382374}
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