Changeset 63284 in vbox for trunk/src/VBox/NetworkServices/NetLib
- Timestamp:
- Aug 10, 2016 3:01:05 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp
r63274 r63284 52 52 53 53 54 static int netPfStrAddressParse(char *pszRaw, size_t c bRaw,54 static int netPfStrAddressParse(char *pszRaw, size_t cchRaw, 55 55 char *pszAddress, int cbAddress, 56 56 bool fEmptyAcceptable) 57 57 { 58 int cbField = 0;58 size_t cchField = 0; 59 59 60 60 AssertPtrReturn(pszRaw, -1); … … 66 66 /* shift pszRaw to next symbol */ 67 67 pszRaw++; 68 c bRaw--;68 cchRaw--; 69 69 70 70 71 71 /* we shouldn't face with ending here */ 72 AssertReturn(c bRaw > 0, VERR_INVALID_PARAMETER);72 AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER); 73 73 74 74 char *pszEndOfAddress = RTStrStr(pszRaw, PF_STR_ADDRESS_FIELD_ENDS); … … 77 77 AssertPtrReturn(pszEndOfAddress, VERR_INVALID_PARAMETER); 78 78 79 c bField = pszEndOfAddress - pszRaw;79 cchField = pszEndOfAddress - pszRaw; 80 80 81 81 /* field should be less then the rest of the string */ 82 AssertReturn(c bField < cbRaw, VERR_INVALID_PARAMETER);83 84 if (c bField != 0)85 RTStrCopy(pszAddress, RT_MIN(c bField + 1, cbAddress), pszRaw);82 AssertReturn(cchField < cchRaw, VERR_INVALID_PARAMETER); 83 84 if (cchField != 0) 85 RTStrCopy(pszAddress, RT_MIN(cchField + 1, cbAddress), pszRaw); 86 86 else if (!fEmptyAcceptable) 87 87 return -1; 88 88 } 89 89 90 AssertReturn(pszRaw[c bField] == 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 */ 93 93 } 94 94 … … 134 134 135 135 pszRaw++; /* skip field separator */ 136 c bRaw --;136 cchRaw --; 137 137 138 138 char *pszEndOfPort = RTStrStr(pszRaw, ":"); … … 141 141 cbRest = strlen(pszRaw); 142 142 143 Assert(c bRaw == cbRest);143 Assert(cchRaw == cbRest); 144 144 145 145 /* XXX: Assumption that if string is too big, it will be reported by … … 178 178 179 179 180 static int netPfStrAddressPortPairParse(char *pszRaw, size_t c bRaw,180 static int netPfStrAddressPortPairParse(char *pszRaw, size_t cchRaw, 181 181 char *pszAddress, int cbAddress, 182 182 bool fEmptyAddressAcceptable, … … 195 195 196 196 pszRaw++; /* field separator skip */ 197 c bRaw--;198 AssertReturn(c bRaw > 0, VERR_INVALID_PARAMETER);197 cchRaw--; 198 AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER); 199 199 200 200 idxRaw = 0; … … 203 203 { 204 204 idxRaw += netPfStrAddressParse(pszRaw, 205 c bRaw - idxRaw,205 cchRaw - idxRaw, 206 206 pszAddress, 207 207 cbAddress, … … 216 216 pszRaw += idxRaw; 217 217 idxRawTotal += idxRaw; 218 c bRaw -= idxRaw;219 220 AssertReturn(c bRaw > 0, VERR_INVALID_PARAMETER);218 cchRaw -= idxRaw; 219 220 AssertReturn(cchRaw > 0, VERR_INVALID_PARAMETER); 221 221 222 222 idxRaw = 0; … … 265 265 char *pszName = &pPfr->szPfrName[0]; 266 266 267 size_t c bRaw = strlen(pcszStrPortForward);267 size_t cchRaw = strlen(pcszStrPortForward); 268 268 269 269 /* Minimal rule ":tcp:[]:0:[]:0" has got lenght 14 */ 270 AssertReturn(c bRaw > 14, VERR_INVALID_PARAMETER);270 AssertReturn(cchRaw > 14, VERR_INVALID_PARAMETER); 271 271 272 272 char *pszRaw = RTStrDup(pcszStrPortForward); … … 286 286 cbToken = pszEndOfName - pszRaw; /* don't take : into account */ 287 287 /* XXX it's unacceptable to have only name entry in PF */ 288 AssertReturn(cbToken < c bRaw, VERR_INVALID_PARAMETER);288 AssertReturn(cbToken < cchRaw, VERR_INVALID_PARAMETER); 289 289 290 290 if ( cbToken < 0 … … 296 296 pszRaw); 297 297 pszRaw += cbToken; /* move to separator */ 298 c bRaw -= cbToken;298 cchRaw -= cbToken; 299 299 } 300 300 … … 303 303 304 304 pszRaw++; /* skip separator */ 305 c bRaw--;305 cchRaw--; 306 306 idxRaw = 0; 307 307 … … 317 317 318 318 pszRaw += idxRaw; 319 c bRaw -= idxRaw;320 321 idxRaw = netPfStrAddressPortPairParse(pszRaw, c bRaw,319 cchRaw -= idxRaw; 320 321 idxRaw = netPfStrAddressPortPairParse(pszRaw, cchRaw, 322 322 pszHostAddr, INET6_ADDRSTRLEN, 323 323 true, &u16HostPort); … … 326 326 327 327 pszRaw += idxRaw; 328 c bRaw -= idxRaw;328 cchRaw -= idxRaw; 329 329 330 330 Assert(pszRaw[0] == PF_FIELD_SEPARATOR); 331 331 332 idxRaw = netPfStrAddressPortPairParse(pszRaw, c bRaw,332 idxRaw = netPfStrAddressPortPairParse(pszRaw, cchRaw, 333 333 pszGuestAddr, INET6_ADDRSTRLEN, 334 334 false, &u16GuestPort);
Note:
See TracChangeset
for help on using the changeset viewer.