- Timestamp:
- Mar 21, 2018 2:30:29 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/net/netaddrstr2.cpp
r69111 r71435 72 72 if (ppszNext != NULL) 73 73 *ppszNext = pszNext; 74 return VINF_SUCCESS;74 return rc; 75 75 } 76 76 … … 94 94 pcszAddr = RTStrStripL(pcszAddr); 95 95 rc = rtNetStrToIPv4AddrEx(pcszAddr, pAddr, &pszNext); 96 if (rc != VINF_SUCCESS) 97 return VERR_INVALID_PARAMETER; 98 99 pszNext = RTStrStripL(pszNext); 100 if (*pszNext != '\0') 96 if (RT_FAILURE(rc) || rc == VWRN_TRAILING_CHARS) 101 97 return VERR_INVALID_PARAMETER; 102 98 … … 138 134 pcszAddr = RTStrStripL(pcszAddr); 139 135 rc = rtNetStrToIPv4AddrEx(pcszAddr, &addrIPv4, &pszNext); 140 if (rc != VINF_SUCCESS) 141 return false; 142 143 pszNext = RTStrStripL(pszNext); 144 if (*pszNext != '\0') 136 if (RT_FAILURE(rc) || rc == VWRN_TRAILING_CHARS) 145 137 return false; 146 138 -
trunk/src/VBox/Runtime/testcase/tstRTNetIPv4.cpp
r69111 r71435 97 97 98 98 99 #define CHECKISADDR(String, fExpected) \ 100 do { \ 101 bool fRc = RTNetIsIPv4AddrStr(String); \ 102 if (fRc != fExpected) \ 103 { \ 104 RTTestIFailed("at line %d: '%s':" \ 105 " expected %RTbool got %RTbool\n", \ 106 __LINE__, (String), fExpected, fRc); \ 107 } \ 108 } while (0) 109 110 #define IS_ADDR(String) CHECKISADDR((String), true) 111 #define NOT_ADDR(String) CHECKISADDR((String), false) 112 113 99 114 #define CHECKANY(String, fExpected) \ 100 115 do { \ … … 256 271 */ 257 272 CHECKADDREX("1.2.3.4", "", VINF_SUCCESS, 0x01020304); 258 CHECKADDREX("1.2.3.4", " ", V INF_SUCCESS,0x01020304);259 CHECKADDREX("1.2.3.4", "x", V INF_SUCCESS,0x01020304);273 CHECKADDREX("1.2.3.4", " ", VWRN_TRAILING_SPACES, 0x01020304); 274 CHECKADDREX("1.2.3.4", "x", VWRN_TRAILING_CHARS, 0x01020304); 260 275 CHECKADDREX("1.2.3.444", "", VERR_INVALID_PARAMETER, 0); 261 276 277 /* NB: RTNetIsIPv4AddrStr does NOT allow leading/trailing whitespace */ 278 IS_ADDR("1.2.3.4"); 279 NOT_ADDR(" 1.2.3.4"); 280 NOT_ADDR("1.2.3.4 "); 281 NOT_ADDR("1.2.3.4x"); 262 282 263 283 IS_ANY("0.0.0.0"); 264 IS_ANY("\t 0.0.0.0 \t"); 284 IS_ANY("\t 0.0.0.0 \t"); /* ... but RTNetStrIsIPv4AddrAny does */ 265 285 266 286 NOT_ANY("1.1.1.1"); /* good address, but not INADDR_ANY */
Note:
See TracChangeset
for help on using the changeset viewer.