Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
c3e74008
Commit
c3e74008
authored
Feb 15, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openvpn: validate IPv4 CIDR more strictly to prevent OpenVPN startup error; closes #1389
parent
4462372b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
openvpn.inc
src/etc/inc/openvpn.inc
+9
-3
No files found.
src/etc/inc/openvpn.inc
View file @
c3e74008
...
@@ -284,13 +284,19 @@ function openvpn_validate_cidr($value, $name, $multiple = false, $ipproto = "ipv
...
@@ -284,13 +284,19 @@ function openvpn_validate_cidr($value, $name, $multiple = false, $ipproto = "ipv
}
}
}
}
function
openvpn_validate_cidr_ipv4
(
$value
)
{
function
openvpn_validate_cidr_ipv4
(
$value
)
{
$value
=
trim
(
$value
);
$value
=
trim
(
$value
);
if
(
!
empty
(
$value
))
{
if
(
!
empty
(
$value
))
{
list
(
$ip
,
$mask
)
=
explode
(
'/'
,
$value
);
list
(
$ip
,
$mask
)
=
explode
(
'/'
,
$value
);
if
(
!
is_ipaddrv4
(
$ip
)
or
!
is_numeric
(
$mask
)
or
(
$mask
>
32
)
or
(
$mask
<
0
))
{
if
(
!
is_ipaddrv4
(
$ip
)
or
!
is_numeric
(
$mask
)
or
(
$mask
>
32
)
or
(
$mask
<
0
))
{
return
false
;
return
false
;
}
}
/* IPv4 case is very strict, cannot be a host address */
$mask
=
(
0xffffffff
<<
(
32
-
$mask
))
&
0xffffffff
;
if
((
ip2long
(
$ip
)
&
$mask
)
!=
ip2long
(
$ip
))
{
return
false
;
}
}
}
return
true
;
return
true
;
}
}
...
@@ -301,7 +307,7 @@ function openvpn_validate_cidr_ipv6($value)
...
@@ -301,7 +307,7 @@ function openvpn_validate_cidr_ipv6($value)
if
(
!
empty
(
$value
))
{
if
(
!
empty
(
$value
))
{
list
(
$ipv6
,
$prefix
)
=
explode
(
'/'
,
$value
);
list
(
$ipv6
,
$prefix
)
=
explode
(
'/'
,
$value
);
if
(
empty
(
$prefix
))
{
if
(
empty
(
$prefix
))
{
$prefix
=
"128"
;
$prefix
=
'128'
;
}
}
if
(
!
is_ipaddrv6
(
$ipv6
)
or
!
is_numeric
(
$prefix
)
or
(
$prefix
>
128
)
or
(
$prefix
<
0
))
{
if
(
!
is_ipaddrv6
(
$ipv6
)
or
!
is_numeric
(
$prefix
)
or
(
$prefix
>
128
)
or
(
$prefix
<
0
))
{
return
false
;
return
false
;
...
@@ -310,7 +316,7 @@ function openvpn_validate_cidr_ipv6($value)
...
@@ -310,7 +316,7 @@ function openvpn_validate_cidr_ipv6($value)
return
true
;
return
true
;
}
}
function
openvpn_add_dhcpopts
(
&
$settings
,
&
$conf
)
function
openvpn_add_dhcpopts
(
&
$settings
,
&
$conf
)
{
{
if
(
!
empty
(
$settings
[
'dns_domain'
]))
{
if
(
!
empty
(
$settings
[
'dns_domain'
]))
{
$conf
.=
"push
\"
dhcp-option DOMAIN
{
$settings
[
'dns_domain'
]
}
\"\n
"
;
$conf
.=
"push
\"
dhcp-option DOMAIN
{
$settings
[
'dns_domain'
]
}
\"\n
"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment