VirtualBox

Changeset 91919 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Oct 21, 2021 1:10:52 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147724
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.

(should have been part of r147723).

Location:
trunk/src/VBox/Runtime/testcase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstRTNetIPv4.cpp

    r91766 r91919  
    319319    GOODCIDR("1.2.3.4/255.255.255.255", 0x01020304, 32);
    320320
    321 #if 0
    322     /** @todo doesn't support 0/0 yet */
    323321    GOODCIDR("0.0.0.0/0",       0x00000000,  0);
    324322    GOODCIDR("0.0.0.0/0x0",     0x00000000,  0);
    325323    GOODCIDR("0.0.0.0/0.0.0.0", 0x00000000,  0);
    326 #endif
     324
     325    /*
     326     * we allow zero prefix mostly for the sake of the above
     327     * "everything"/default case, but allow it on everything - a
     328     * conscientious caller should be doing more checks on the result
     329     * anyway.
     330     */
     331    GOODCIDR("1.2.3.4/0",       0x01020304,  0);        /* prefix can be zero */
    327332
    328333    GOODCIDR("\t " "1.2.3.4/24",       0x01020304, 24); /* leading spaces ok */
     
    339344    BADCIDR("1.2.3.4/240.");
    340345
    341     BADCIDR("1.2.3.4/0");       /* prefix can't be zero */
    342346    BADCIDR("1.2.3.4/33");      /* prefix is too big */
     347    BADCIDR("1.2.3.4/256");     /* prefix is too big */
     348    BADCIDR("1.2.3.4/257");     /* prefix is too big */
    343349    BADCIDR("1.2.3.4/-1");      /* prefix is negative */
    344350    BADCIDR("1.2.3.4/");        /* prefix is missing */
  • trunk/src/VBox/Runtime/testcase/tstRTNetIPv6.cpp

    r91767 r91919  
    247247    GOODCIDR("1:2:3:4::%if/64", 0x00010002, 0x00030004,          0,          0,  64);
    248248
    249 #if 0
    250     /** @todo doesn't support ::/0 yet */
     249
    251250    GOODCIDR("::/0", 0, 0, 0, 0, 0);
    252 #endif
     251
     252    /*
     253     * we allow zero prefix mostly for the sake of the above
     254     * "everything"/default case, but allow it on everything - a
     255     * conscientious caller should be doing more checks on the result
     256     * anyway.
     257     */
     258    GOODCIDR("1:2:3:4::/0",    0x00010002, 0x00030004,          0,          0,    0);
     259
    253260
    254261    BADCIDR("1:2:3:4:: 64");
    255262    BADCIDR("1:2:3:4::/64x");
    256     BADCIDR("1:2:3:4::/0");
    257263    BADCIDR("1:2:3:4::/-1");
    258264    BADCIDR("1:2:3:4::/129");
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette