Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
c9559407
Commit
c9559407
authored
9 years ago
by
Olav Morken
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:simplesamlphp/simplesamlphp
parents
08c8bbc9
daf2696b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/SimpleSAML/Utils/Net.php
+4
-4
4 additions, 4 deletions
lib/SimpleSAML/Utils/Net.php
tests/Utils/NetTest.php
+36
-1
36 additions, 1 deletion
tests/Utils/NetTest.php
with
40 additions
and
5 deletions
lib/SimpleSAML/Utils/Net.php
+
4
−
4
View file @
c9559407
...
@@ -20,7 +20,7 @@ class Net
...
@@ -20,7 +20,7 @@ class Net
*
*
* @author Andreas Åkre Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Andreas Åkre Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
* @author Brook Schofield,
TERENA
* @author Brook Schofield,
GÉANT
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
*/
static
function
ipCIDRcheck
(
$cidr
,
$ip
=
null
)
static
function
ipCIDRcheck
(
$cidr
,
$ip
=
null
)
...
@@ -38,11 +38,11 @@ class Net
...
@@ -38,11 +38,11 @@ class Net
// Validate IPv6 with inet_pton, convert to hex with bin2hex
// Validate IPv6 with inet_pton, convert to hex with bin2hex
// then store as a long with hexdec
// then store as a long with hexdec
$ip_pack
=
inet_pton
(
$ip
);
$ip_pack
=
@
inet_pton
(
$ip
);
$net_pack
=
inet_pton
(
$net
);
$net_pack
=
@
inet_pton
(
$net
);
if
(
$ip_pack
===
false
||
$net_pack
===
false
)
{
if
(
$ip_pack
===
false
||
$net_pack
===
false
)
{
// not valid IPv6 address (warning
already issu
ed)
// not valid IPv6 address (warning
silenc
ed)
return
false
;
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/Utils/NetTest.php
+
36
−
1
View file @
c9559407
...
@@ -39,4 +39,39 @@ class Utils_Net_Test extends PHPUnit_Framework_TestCase
...
@@ -39,4 +39,39 @@ class Utils_Net_Test extends PHPUnit_Framework_TestCase
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'127.0.0.0/23'
,
'127.0.1.256'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'127.0.0.0/23'
,
'127.0.1.256'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'127.0.0.0/23'
,
'127.0.2.0'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'127.0.0.0/23'
,
'127.0.2.0'
));
}
}
}
\ No newline at end of file
public
function
testIpv6CIDRcheck
()
{
// check CIDR w/o mask
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::'
,
'2001:0DB8::1'
));
// check wrong CIDR w/ mask
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/128'
,
'2001:0DB8::1'
));
// check wrong IP
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/128'
,
'2001:0DB8::Z'
));
// check limits for standard classes
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/128'
,
'2001:0DB8:0000:0000:0000:0000:0000:0000'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/128'
,
'2001:0DB8::0'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/128'
,
'2001:0DB8::1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/112'
,
'2001:0DB8::1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/112'
,
'2001:0DB8::1:1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/112'
,
'2001:0DB8::FFFF'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/112'
,
'2001:0DB8::1:FFFF'
));
// check limits for non-standard classes
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/108'
,
'2001:0DB8::1:1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/108'
,
'2001:0DB8::F:1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/108'
,
'2001:0DB8::FF:1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/108'
,
'2001:0DB8::1FF:1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/108'
,
'2001:0DB8::FFFF:1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/104'
,
'2001:0DB8::1:1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/104'
,
'2001:0DB8::F:1'
));
$this
->
assertTrue
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/104'
,
'2001:0DB8::FF:1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/104'
,
'2001:0DB8::1FF:1'
));
$this
->
assertFalse
(
SimpleSAML\Utils\Net
::
ipCIDRcheck
(
'2001:0DB8::/104'
,
'2001:0DB8::FFFF:1'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment