VirtualBox

Changeset 91918 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Oct 21, 2021 1:09:34 AM (3 years ago)
Author:
vboxsync
Message:

IPRT: Make RTNetStrToIPv4Cidr() and RTNetStrToIPv4Cidr() accept zero
prefix, mostly for the benefit of 0.0.0.0/0 and ::/0 respectively.

While here fix RTNetStrToIPv6Cidr to do stricter checks on the prefix.
When the number is too big RTStrToUInt8Ex returns a warning, not an
error. bugref:9330.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/net/netaddrstr2.cpp

    r87524 r91918  
    291291    }
    292292
    293     if (u8Prefix == 0 || u8Prefix > 32)
     293    if (u8Prefix > 32)
    294294        return VERR_INVALID_PARAMETER;
    295295
     
    715715    ++pszNext;
    716716    rc = RTStrToUInt8Ex(pszNext, &pszNext, 10, &u8Prefix);
    717     if (RT_FAILURE(rc) || rc == VWRN_TRAILING_CHARS)
    718         return VERR_INVALID_PARAMETER;
    719 
    720     if (u8Prefix == 0 || u8Prefix > 128)
     717    if (rc != VINF_SUCCESS && rc != VWRN_TRAILING_SPACES)
     718        return VERR_INVALID_PARAMETER;
     719
     720    if (u8Prefix > 128)
    721721        return VERR_INVALID_PARAMETER;
    722722
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