ovpnmain.cgi: Validate CCDNet name when renaming it.

Message ID 20200128105150.5848-1-stefan.schantl@ipfire.org
State Accepted
Commit 7ad653cc09409c4e23885bf89279bd8458189f11
Headers
Series ovpnmain.cgi: Validate CCDNet name when renaming it. |

Commit Message

Stefan Schantl Jan. 28, 2020, 10:51 a.m. UTC
  Fixes #12282

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/ovpnmain.cgi | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Michael Tremer Jan. 28, 2020, 3:33 p.m. UTC | #1
Hi,

> On 28 Jan 2020, at 10:51, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Fixes #12282
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> html/cgi-bin/ovpnmain.cgi | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
> index e76a688fe..22a2b9905 100644
> --- a/html/cgi-bin/ovpnmain.cgi
> +++ b/html/cgi-bin/ovpnmain.cgi
> @@ -490,6 +490,13 @@ sub modccdnet
> 	my $oldname=$_[1];
> 	my %ccdconfhash=();
> 	my %ccdhash=();
> +
> +	# Check if the new name is valid.
> +	if(!&General::validhostname($newname)) {
> +		$errormessage=$Lang::tr{'ccd err invalidname'};
> +		return;
> +	}
> +

Why does the name of the pool need to be a FQDN?

> 	&General::readhasharray("${General::swroot}/ovpn/ccd.conf", \%ccdconfhash);
> 	foreach my $key (keys %ccdconfhash) {
> 		if ($ccdconfhash{$key}[0] eq $oldname) {
> -- 
> 2.25.0
>
  
Michael Tremer Jan. 30, 2020, 12:55 p.m. UTC | #2
Okay. Can you ask the reporter to check your changes and confirm here on the list?

> On 30 Jan 2020, at 12:48, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Hello Michael,
> 
> thanks for reviewing the patch.
> 
> There is no need that the pool name is a FQDN, I mainly inserted the
> same check when editing as when adding a new pool.
> 
> Best regards,
> 
> -Stefan
>> Hi,
>> 
>>> On 28 Jan 2020, at 10:51, Stefan Schantl <stefan.schantl@ipfire.org
>>>> wrote:
>>> 
>>> Fixes #12282
>>> 
>>> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
>>> ---
>>> html/cgi-bin/ovpnmain.cgi | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>> 
>>> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
>>> index e76a688fe..22a2b9905 100644
>>> --- a/html/cgi-bin/ovpnmain.cgi
>>> +++ b/html/cgi-bin/ovpnmain.cgi
>>> @@ -490,6 +490,13 @@ sub modccdnet
>>> 	my $oldname=$_[1];
>>> 	my %ccdconfhash=();
>>> 	my %ccdhash=();
>>> +
>>> +	# Check if the new name is valid.
>>> +	if(!&General::validhostname($newname)) {
>>> +		$errormessage=$Lang::tr{'ccd err invalidname'};
>>> +		return;
>>> +	}
>>> +
>> 
>> Why does the name of the pool need to be a FQDN?
>> 
>>> 	&General::readhasharray("${General::swroot}/ovpn/ccd.conf",
>>> \%ccdconfhash);
>>> 	foreach my $key (keys %ccdconfhash) {
>>> 		if ($ccdconfhash{$key}[0] eq $oldname) {
>>> -- 
>>> 2.25.0
>>> 
>
  

Patch

diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
index e76a688fe..22a2b9905 100644
--- a/html/cgi-bin/ovpnmain.cgi
+++ b/html/cgi-bin/ovpnmain.cgi
@@ -490,6 +490,13 @@  sub modccdnet
 	my $oldname=$_[1];
 	my %ccdconfhash=();
 	my %ccdhash=();
+
+	# Check if the new name is valid.
+	if(!&General::validhostname($newname)) {
+		$errormessage=$Lang::tr{'ccd err invalidname'};
+		return;
+	}
+
 	&General::readhasharray("${General::swroot}/ovpn/ccd.conf", \%ccdconfhash);
 	foreach my $key (keys %ccdconfhash) {
 		if ($ccdconfhash{$key}[0] eq $oldname) {