From mboxrd@z Thu Jan  1 00:00:00 1970
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject:
 [PATCH] vpnmain.cgi+ovpnmain.cgi: Fix file upload with new versions of Perl
Date: Mon, 14 Oct 2019 19:11:37 +0200
Message-ID: <20191014171137.23722-1-michael.tremer@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============8383222768609777932=="
List-Id: <development.lists.ipfire.org>

--===============8383222768609777932==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

File uploads did not work since Perl was upgraded. This patch
fixes that problem by only checking if an object was returned
instead of performing a string comparison.

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 html/cgi-bin/ovpnmain.cgi | 16 +++++++---------
 html/cgi-bin/vpnmain.cgi  | 10 +++++-----
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
index 5b8ca9731..970444a55 100644
--- a/html/cgi-bin/ovpnmain.cgi
+++ b/html/cgi-bin/ovpnmain.cgi
@@ -1372,7 +1372,7 @@ END
 ### Upload DH key
 ###
 } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload dh key'}) {
-    if (ref ($cgiparams{'FH'}) ne 'Fh') {
+    unless (ref ($cgiparams{'FH'})) {
          $errormessage =3D $Lang::tr{'there was no file upload'};
          goto UPLOADCA_ERROR;
     }
@@ -1429,7 +1429,7 @@ END
 	}
     }
=20
-    if (ref ($cgiparams{'FH'}) ne 'Fh') {
+    unless (ref ($cgiparams{'FH'})) {
 	$errormessage =3D $Lang::tr{'there was no file upload'};
 	goto UPLOADCA_ERROR;
     }
@@ -1662,8 +1662,7 @@ END
 	    }
 	}
     } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload p12 file'}) {
-
-	if (ref ($cgiparams{'FH'}) ne 'Fh') {
+	unless (ref ($cgiparams{'FH'})) {
 	    $errormessage =3D $Lang::tr{'there was no file upload'};
 	    goto ROOTCERT_ERROR;
 	}
@@ -3218,9 +3217,8 @@ END
=20
 	&General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash)=
;=09
=20
-# Check if a file is uploaded
-
-	if (ref ($cgiparams{'FH'}) ne 'Fh') {
+	# Check if a file is uploaded
+	unless (ref ($cgiparams{'FH'})) {
 		$errormessage =3D $Lang::tr{'there was no file upload'};
 		goto N2N_ERROR;
     }
@@ -4009,7 +4007,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
 		$errormessage =3D $Lang::tr{'cant change certificates'};
 		goto VPNCONF_ERROR;
 	    }
-	    if (ref ($cgiparams{'FH'}) ne 'Fh') {
+	    unless (ref ($cgiparams{'FH'})) {
 		$errormessage =3D $Lang::tr{'there was no file upload'};
 		goto VPNCONF_ERROR;
 	    }
@@ -4056,7 +4054,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
 		$errormessage =3D $Lang::tr{'cant change certificates'};
 		goto VPNCONF_ERROR;
 	    }
-	    if (ref ($cgiparams{'FH'}) ne 'Fh') {
+	    unless (ref ($cgiparams{'FH'})) {
 		$errormessage =3D $Lang::tr{'there was no file upload'};
 		goto VPNCONF_ERROR;
 	    }
diff --git a/html/cgi-bin/vpnmain.cgi b/html/cgi-bin/vpnmain.cgi
index 1cd7cb84b..33b504bc9 100644
--- a/html/cgi-bin/vpnmain.cgi
+++ b/html/cgi-bin/vpnmain.cgi
@@ -604,7 +604,7 @@ END
 		}
 	}
=20
-	if (ref ($cgiparams{'FH'}) ne 'Fh') {
+	unless (ref ($cgiparams{'FH'})) {
 		$errormessage =3D $Lang::tr{'there was no file upload'};
 		goto UPLOADCA_ERROR;
 	}
@@ -830,7 +830,7 @@ END
 	} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'upload p12 file'}) {
 		&General::log("ipsec", "Importing from p12...");
=20
-		if (ref ($cgiparams{'FH'}) ne 'Fh') {
+		unless (ref ($cgiparams{'FH'})) {
 			$errormessage =3D $Lang::tr{'there was no file upload'};
 			goto ROOTCERT_ERROR;
 		}
@@ -1531,7 +1531,7 @@ END
 			$errormessage =3D $Lang::tr{'cant change certificates'};
 			goto VPNCONF_ERROR;
 		}
-		if (ref ($cgiparams{'FH'}) ne 'Fh') {
+		unless (ref ($cgiparams{'FH'})) {
 			$errormessage =3D $Lang::tr{'there was no file upload'};
 			goto VPNCONF_ERROR;
 		}
@@ -1568,7 +1568,7 @@ END
 	} elsif ($cgiparams{'AUTH'} eq 'pkcs12') {
 		&General::log("ipsec", "Importing from p12...");
=20
-		if (ref ($cgiparams{'FH'}) ne 'Fh') {
+		unless (ref ($cgiparams{'FH'})) {
 			$errormessage =3D $Lang::tr{'there was no file upload'};
 			goto ROOTCERT_ERROR;
 		}
@@ -1658,7 +1658,7 @@ END
 			$errormessage =3D $Lang::tr{'cant change certificates'};
 			goto VPNCONF_ERROR;
 		}
-		if (ref ($cgiparams{'FH'}) ne 'Fh') {
+		unless (ref ($cgiparams{'FH'})) {
 			$errormessage =3D $Lang::tr{'there was no file upload'};
 			goto VPNCONF_ERROR;
 		}
--=20
2.12.2


--===============8383222768609777932==--