Overlapping check does not work - Fixes provided
phpipam open-source IP address management
Brought to you by:
myha
Within the verifyNestedSubnetOverlapping function in functions-network.php, there is a bug that prevents checking of overlapping subnets:
if($existingSubnet['id'] = $kp) {
should be
if($existingSubnet['id'] == $kp) {
I guess.
Also in manageSubnetEditResult.php at line #85:
if($section['strictMode'] == 1 && !$isFolder) {
should be
if ($section['strictMode'] == 1 ) {
because $isFolder is always set to true if the masterSubnetId is 0 and the if:
else if (($_POST['action'] == "add") && ($_POST['masterSubnetId'] == 0)) {
wouldn't make any sense.
Could you please fix this in the upcoming versions?
Anonymous
ah damn, no it always says overlapping
Okay, I think it works now like this:
$allParents = getAllParents($masterSubnetId);
foreach ($allParents as $kp => $p) {
if ($existingSubnet['id'] == $p) { // $kp is either 0 or 1, so use $p instead and of course == instead of =
$ignore = true;
}
}
if ($masterSubnetId == $existingSubnet['id']) { //don't check against the masterSubnet
$ignore = true;
}
AND:
add a "$ignore = false;" at the top of the foreach loop, otherwise once it's true it's always true...
Hmm, I'm seeing the same on 1.01. I introduced the "fixes" proposed by the Anonymous and now it works as expected, but I'm unsure if it breaks something else (there might be use cases I don't see/need).
Could you please review the patch?
OK, first issue with the patch. I you put the subnets in folders, the check doesn't work.
Well, but how do you use the folders?
I mean, if I got one folder with the subnets 192.168.0.0/16 -> (child) 192.168.1.0/24
And now I want to put the child subnet into a new folder called "Test". What exactly do you want do be checked? Should it be checked with all other subnets within the section?
Because then you couldn't put any 192.168.0.0 network in a folder.
I personally don't use the folders, so it depends on how you want to use them.
Would be great, if you can answer me this question so I might provide a bugfix :)
Can someone checks this on original file:
Just change the last true to false.
Fixed, will be available in 1.1
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
This is still a problem in 1.1, FYI