Changeset 65611 in vbox
- Timestamp:
- Feb 4, 2017 1:20:20 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 113282
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
r65580 r65611 262 262 rc = RTNetStrToIPv4Addr(aIPAddress.c_str(), &IPAddress); 263 263 if (RT_FAILURE(rc)) 264 return E_INVALIDARG; 264 return mVirtualBox->setErrorBoth(E_INVALIDARG, rc, 265 "Invalid server address"); 265 266 266 267 rc = RTNetStrToIPv4Addr(aNetworkMask.c_str(), &NetworkMask); 267 268 if (RT_FAILURE(rc)) 268 return E_INVALIDARG; 269 return mVirtualBox->setErrorBoth(E_INVALIDARG, rc, 270 "Invalid netmask"); 269 271 270 272 rc = RTNetStrToIPv4Addr(aLowerIP.c_str(), &LowerIP); 271 273 if (RT_FAILURE(rc)) 272 return E_INVALIDARG; 274 return mVirtualBox->setErrorBoth(E_INVALIDARG, rc, 275 "Invalid range lower address"); 273 276 274 277 rc = RTNetStrToIPv4Addr(aUpperIP.c_str(), &UpperIP); 275 278 if (RT_FAILURE(rc)) 276 return E_INVALIDARG; 279 return mVirtualBox->setErrorBoth(E_INVALIDARG, rc, 280 "Invalid range upper address"); 277 281 278 282 /* … … 282 286 rc = RTNetMaskToPrefixIPv4(&NetworkMask, NULL); 283 287 if (RT_FAILURE(rc)) 284 return E_INVALIDARG; 288 return mVirtualBox->setErrorBoth(E_INVALIDARG, rc, 289 "Invalid netmask"); 285 290 286 291 /* It's more convenient to convert to host order once */ … … 290 295 UpperIP.u = RT_N2H_U32(UpperIP.u); 291 296 292 /* Addresses must be unicast */ 293 if ( (IPAddress.u & 0xe0000000) == 0xe0000000 294 || (LowerIP.u & 0xe0000000) == 0xe0000000 295 || (UpperIP.u & 0xe0000000) == 0xe0000000) 296 { 297 return E_INVALIDARG; 298 } 299 300 /* Addresses should be from the same network */ 301 if ( (IPAddress.u & NetworkMask.u) != (LowerIP.u &NetworkMask.u) 302 || (LowerIP.u & NetworkMask.u) != (UpperIP.u &NetworkMask.u)) 303 { 304 return E_INVALIDARG; 297 /* 298 * Addresses must be unicast and from the same network 299 */ 300 if ( (IPAddress.u & UINT32_C(0xe0000000)) == UINT32_C(0xe0000000) 301 || (IPAddress.u & ~NetworkMask.u) == 0 302 || ((IPAddress.u & ~NetworkMask.u) | NetworkMask.u) == UINT32_C(0xffffffff)) 303 { 304 return mVirtualBox->setError(E_INVALIDARG, 305 "Invalid server address"); 306 } 307 308 if ( (LowerIP.u & UINT32_C(0xe0000000)) == UINT32_C(0xe0000000) 309 || (LowerIP.u & NetworkMask.u) != (IPAddress.u &NetworkMask.u) 310 || (LowerIP.u & ~NetworkMask.u) == 0 311 || ((LowerIP.u & ~NetworkMask.u) | NetworkMask.u) == UINT32_C(0xffffffff)) 312 { 313 return mVirtualBox->setError(E_INVALIDARG, 314 "Invalid range lower address"); 315 } 316 317 if ( (UpperIP.u & UINT32_C(0xe0000000)) == UINT32_C(0xe0000000) 318 || (UpperIP.u & NetworkMask.u) != (IPAddress.u &NetworkMask.u) 319 || (UpperIP.u & ~NetworkMask.u) == 0 320 || ((UpperIP.u & ~NetworkMask.u) | NetworkMask.u) == UINT32_C(0xffffffff)) 321 { 322 return mVirtualBox->setError(E_INVALIDARG, 323 "Invalid range upper address"); 305 324 } 306 325 307 326 /* The range should be valid ... */ 308 327 if (LowerIP.u > UpperIP.u) 309 return E_INVALIDARG; 328 return mVirtualBox->setError(E_INVALIDARG, 329 "Invalid range bounds"); 310 330 311 331 /* ... and shouldn't contain the server's address */ 312 332 if (LowerIP.u <= IPAddress.u && IPAddress.u <= UpperIP.u) 313 return E_INVALIDARG;314 333 return mVirtualBox->setError(E_INVALIDARG, 334 "Server address within range bounds"); 315 335 316 336 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
Note:
See TracChangeset
for help on using the changeset viewer.