- 時間撮記:
- 2016-8-10 下午02:17:15 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp
r63272 r63274 51 51 #define PF_STR_ADDRESS_FIELD_ENDS "]" 52 52 53 static int netPfStrAddressParse(char *pszRaw, int cbRaw, 53 54 static int netPfStrAddressParse(char *pszRaw, size_t cbRaw, 54 55 char *pszAddress, int cbAddress, 55 56 bool fEmptyAcceptable) … … 100 101 * @param pszRaw The zero terminated string to parse. Points a field 101 102 * separator. 102 * @param cbRaw Number of valid bytes in the buffer @a pszRaw points103 * at. (Ignored since pszRaw is terminated.)104 103 * @param pu16Port Where to store the port number on success. 105 104 */ 106 static int netPfStrPortParse(char *pszRaw, int cbRaw,uint16_t *pu16Port)105 static int netPfStrPortParse(char *pszRaw, uint16_t *pu16Port) 107 106 { 108 107 #if 1 … … 121 120 if (*pu16Port == 0) 122 121 return -1; 123 Assert((uinpttr_t)pszNext <= (uintptr_t)&pszRaw[cbRaw]); NOREF(cbRaw);124 122 return (int)(pszNext - pszRaw); 125 123 … … 180 178 181 179 182 static int netPfStrAddressPortPairParse(char *pszRaw, int cbRaw,180 static int netPfStrAddressPortPairParse(char *pszRaw, size_t cbRaw, 183 181 char *pszAddress, int cbAddress, 184 182 bool fEmptyAddressAcceptable, … … 228 226 if (pszRaw[0] == PF_FIELD_SEPARATOR) 229 227 { 230 idxRaw = netPfStrPortParse(pszRaw, strlen(pszRaw),pu16Port);228 idxRaw = netPfStrPortParse(pszRaw, pu16Port); 231 229 232 230 Assert(strlen(&pszRaw[idxRaw]) == 0 || pszRaw[idxRaw] == PF_FIELD_SEPARATOR); … … 244 242 /* XXX: Having fIPv6 we might emprove adress verification comparing address length 245 243 * with INET[6]_ADDRLEN 244 * 246 245 */ 247 int netPfStrToPf(const char *pcszStrPortForward, intfIPv6, PPORTFORWARDRULE pPfr)246 int netPfStrToPf(const char *pcszStrPortForward, bool fIPv6, PPORTFORWARDRULE pPfr) 248 247 { 249 char *pszName; 248 /** r=bird: Redo from scratch? This is very hard to read. */ 249 250 250 int proto; 251 char *pszHostAddr;252 char *pszGuestAddr;253 251 uint16_t u16HostPort; 254 252 uint16_t u16GuestPort; 255 253 bool fTcpProto = false; 256 254 257 char *pszRawBegin = NULL;258 char *pszRaw = NULL;259 255 int idxRaw = 0; 260 256 int cbToken = 0; 261 int cbRaw = 0;262 int rc = VINF_SUCCESS;263 257 264 258 AssertPtrReturn(pcszStrPortForward, VERR_INVALID_PARAMETER); … … 267 261 RT_ZERO(*pPfr); 268 262 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); 274 268 275 269 /* Minimal rule ":tcp:[]:0:[]:0" has got lenght 14 */ 276 270 AssertReturn(cbRaw > 14, VERR_INVALID_PARAMETER); 277 271 278 pszRaw = RTStrDup(pcszStrPortForward);272 char *pszRaw = RTStrDup(pcszStrPortForward); 279 273 AssertReturn(pszRaw, VERR_NO_MEMORY); 280 274 281 pszRawBegin = pszRaw;275 char *pszRawBegin = pszRaw; 282 276 283 277 /* name */ … … 290 284 goto invalid_parameter; 291 285 292 cbToken = (pszEndOfName)- pszRaw; /* don't take : into account */286 cbToken = pszEndOfName - pszRaw; /* don't take : into account */ 293 287 /* XXX it's unacceptable to have only name entry in PF */ 294 288 AssertReturn(cbToken < cbRaw, VERR_INVALID_PARAMETER); … … 326 320 327 321 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 328 pszHostAddr, INET6_ADDRSTRLEN,329 true, &u16HostPort);322 pszHostAddr, INET6_ADDRSTRLEN, 323 true, &u16HostPort); 330 324 if (idxRaw < 0) 331 325 return VERR_INVALID_PARAMETER;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器