Commit 3b146027 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) more coding issues

parent 88ca15a1
...@@ -710,7 +710,7 @@ function is_cert_revoked($cert, $crlref = "") { ...@@ -710,7 +710,7 @@ function is_cert_revoked($cert, $crlref = "") {
if (!empty($crlref)) { if (!empty($crlref)) {
$crl = lookup_crl($crlref); $crl = lookup_crl($crlref);
if (!is_array($crl['cert'])) if (!isset($crl['cert']) || !is_array($crl['cert']))
return false; return false;
foreach ($crl['cert'] as $rcert) { foreach ($crl['cert'] as $rcert) {
if (cert_compare($rcert, $cert)) if (cert_compare($rcert, $cert))
...@@ -731,7 +731,7 @@ function is_cert_revoked($cert, $crlref = "") { ...@@ -731,7 +731,7 @@ function is_cert_revoked($cert, $crlref = "") {
function is_openvpn_server_crl($crlref) { function is_openvpn_server_crl($crlref) {
global $config; global $config;
if (!is_array($config['openvpn']['openvpn-server'])) if (!isset($config['openvpn']['openvpn-server']) || !is_array($config['openvpn']['openvpn-server']))
return; return;
foreach ($config['openvpn']['openvpn-server'] as $ovpns) { foreach ($config['openvpn']['openvpn-server'] as $ovpns) {
if (!empty($ovpns['crlref']) && ($ovpns['crlref'] == $crlref)) if (!empty($ovpns['crlref']) && ($ovpns['crlref'] == $crlref))
......
...@@ -1240,7 +1240,7 @@ function openvpn_refresh_crls() { ...@@ -1240,7 +1240,7 @@ function openvpn_refresh_crls() {
openvpn_create_dirs(); openvpn_create_dirs();
if (is_array($config['openvpn']['openvpn-server'])) { if (isset($config['openvpn']['openvpn-server']) && is_array($config['openvpn']['openvpn-server'])) {
foreach ($config['openvpn']['openvpn-server'] as $settings) { foreach ($config['openvpn']['openvpn-server'] as $settings) {
if (empty($settings)) if (empty($settings))
continue; continue;
......
...@@ -59,6 +59,7 @@ echo "N:"; ...@@ -59,6 +59,7 @@ echo "N:";
$result = "NaN"; $result = "NaN";
if ($type == "loggedin") { if ($type == "loggedin") {
$timestamp = 0;
/* Find out the previous user timestamp /* Find out the previous user timestamp
* so we can determine the difference between the current * so we can determine the difference between the current
......
...@@ -80,7 +80,7 @@ if ($act == "del") { ...@@ -80,7 +80,7 @@ if ($act == "del") {
$index = count($a_cert) - 1; $index = count($a_cert) - 1;
for (; $index >=0; $index--) { for (; $index >=0; $index--) {
if ($a_cert[$index]['caref'] == $a_ca[$id]['refid']) { if (isset($a_cert[$index]['caref']) && isset($a_ca[$id]['refid']) && $a_cert[$index]['caref'] == $a_ca[$id]['refid']) {
unset($a_cert[$index]); unset($a_cert[$index]);
} }
} }
......
...@@ -38,10 +38,9 @@ $crl_methods = array( ...@@ -38,10 +38,9 @@ $crl_methods = array(
"internal" => gettext("Create an internal Certificate Revocation List"), "internal" => gettext("Create an internal Certificate Revocation List"),
"existing" => gettext("Import an existing Certificate Revocation List")); "existing" => gettext("Import an existing Certificate Revocation List"));
if (ctype_alnum($_GET['id'])) { if (isset($_GET['id']) && ctype_alnum($_GET['id'])) {
$id = $_GET['id']; $id = $_GET['id'];
} } elseif (isset($_POST['id']) && ctype_alnum($_POST['id'])) {
if (isset($_POST['id']) && ctype_alnum($_POST['id'])) {
$id = $_POST['id']; $id = $_POST['id'];
} }
...@@ -57,7 +56,7 @@ if (!is_array($config['cert'])) { ...@@ -57,7 +56,7 @@ if (!is_array($config['cert'])) {
$a_cert =& $config['cert']; $a_cert =& $config['cert'];
if (!is_array($config['crl'])) { if (!isset($config['crl']) || !is_array($config['crl'])) {
$config['crl'] = array(); $config['crl'] = array();
} }
...@@ -69,9 +68,11 @@ foreach ($a_crl as $cid => $acrl) { ...@@ -69,9 +68,11 @@ foreach ($a_crl as $cid => $acrl) {
} }
} }
$act = $_GET['act']; $act=null;
if ($_POST['act']) { if (isset($_GET['act'])) {
$act = $_POST['act']; $act = $_GET['act'];
} elseif (isset($_POST['act'])) {
$act = $_POST['act'];
} }
if (!empty($id)) { if (!empty($id)) {
...@@ -79,7 +80,7 @@ if (!empty($id)) { ...@@ -79,7 +80,7 @@ if (!empty($id)) {
} }
// If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors. // If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors.
if (!$thiscrl && (($act != "") && ($act != "new"))) { if (!isset($thiscrl) && (($act != "") && ($act != "new"))) {
redirectHeader("system_crlmanager.php"); redirectHeader("system_crlmanager.php");
$act=""; $act="";
$savemsg = gettext("Invalid CRL reference."); $savemsg = gettext("Invalid CRL reference.");
...@@ -101,8 +102,16 @@ if ($act == "del") { ...@@ -101,8 +102,16 @@ if ($act == "del") {
} }
if ($act == "new") { if ($act == "new") {
$pconfig['method'] = $_GET['method']; if (isset($_GET['method'])) {
$pconfig['caref'] = $_GET['caref']; $pconfig['method'] = $_GET['method'];
} else {
$pconfig['method'] = null;
}
if (isset($_GET['caref'])) {
$pconfig['caref'] = $_GET['caref'];
} else {
$pconfig['caref'] = null;
}
$pconfig['lifetime'] = "9999"; $pconfig['lifetime'] = "9999";
$pconfig['serial'] = "0"; $pconfig['serial'] = "0";
} }
...@@ -122,7 +131,7 @@ if ($act == "exp") { ...@@ -122,7 +131,7 @@ if ($act == "exp") {
if ($act == "addcert") { if ($act == "addcert") {
if ($_POST) { if ($_POST) {
unset($input_errors); $input_errors = array();
$pconfig = $_POST; $pconfig = $_POST;
if (!$pconfig['crlref'] || !$pconfig['certref']) { if (!$pconfig['crlref'] || !$pconfig['certref']) {
...@@ -145,7 +154,7 @@ if ($act == "addcert") { ...@@ -145,7 +154,7 @@ if ($act == "addcert") {
$input_errors[] = gettext("Cannot revoke certificates for an imported/external CRL."); $input_errors[] = gettext("Cannot revoke certificates for an imported/external CRL.");
} }
if (!$input_errors) { if (!count($input_errors)) {
$reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason']; $reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason'];
cert_revoke($cert, $crl, $reason); cert_revoke($cert, $crl, $reason);
openvpn_refresh_crls(); openvpn_refresh_crls();
...@@ -216,7 +225,7 @@ if ($_POST) { ...@@ -216,7 +225,7 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$result = false; $result = false;
if ($thiscrl) { if (isset($thiscrl)) {
$crl =& $thiscrl; $crl =& $thiscrl;
} else { } else {
$crl = array(); $crl = array();
...@@ -239,7 +248,7 @@ if ($_POST) { ...@@ -239,7 +248,7 @@ if ($_POST) {
$crl['cert'] = array(); $crl['cert'] = array();
} }
if (!$thiscrl) { if (!isset($thiscrl)) {
$a_crl[] = $crl; $a_crl[] = $crl;
} }
...@@ -296,7 +305,7 @@ include("head.inc"); ...@@ -296,7 +305,7 @@ include("head.inc");
<div class="content-box tab-content"> <div class="content-box tab-content">
<?php if ($act == "new" || $act == gettext("Save") || $input_errors) : <?php if ($act == "new" || $act == gettext("Save") || (isset($input_errors) && count($input_errors)) ) :
?> ?>
<form action="system_crlmanager.php" method="post" name="iform" id="iform"> <form action="system_crlmanager.php" method="post" name="iform" id="iform">
...@@ -310,11 +319,11 @@ include("head.inc"); ...@@ -310,11 +319,11 @@ include("head.inc");
<?php <?php
$rowIndex = 0; $rowIndex = 0;
foreach ($crl_methods as $method => $desc) : foreach ($crl_methods as $method => $desc) :
if (($_GET['importonly'] == "yes") && ($method != "existing")) { if (isset($_GET['importonly']) && ($_GET['importonly'] == "yes") && ($method != "existing")) {
continue; continue;
} }
$selected = ""; $selected = "";
if ($pconfig['method'] == $method) { if (isset($pconfig['method']) && $pconfig['method'] == $method) {
$selected = "selected=\"selected\""; $selected = "selected=\"selected\"";
} }
$rowIndex++; $rowIndex++;
...@@ -336,7 +345,7 @@ endif; ?> ...@@ -336,7 +345,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/> <input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?php if (isset($pconfig['descr'])) echo htmlspecialchars($pconfig['descr']);?>"/>
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -378,7 +387,7 @@ endif; ?> ...@@ -378,7 +387,7 @@ endif; ?>
<tr> <tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("CRL data");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("CRL data");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<textarea name="crltext" id="crltext" cols="65" rows="7" class="formfld_crl"><?=$pconfig['crltext'];?></textarea> <textarea name="crltext" id="crltext" cols="65" rows="7" class="formfld_crl"><?php if (isset($pconfig['crltext'])) echo $pconfig['crltext'];?></textarea>
<br /> <br />
<?=gettext("Paste a Certificate Revocation List in X.509 CRL format here.");?> <?=gettext("Paste a Certificate Revocation List in X.509 CRL format here.");?>
</td> </td>
...@@ -483,7 +492,7 @@ elseif ($act == "edit") : ...@@ -483,7 +492,7 @@ elseif ($act == "edit") :
</thead> </thead>
<tbody> <tbody>
<?php /* List Certs on CRL */ <?php /* List Certs on CRL */
if (!is_array($crl['cert']) || (count($crl['cert']) == 0)) : if (!isset($crl['cert']) || !is_array($crl['cert']) || (count($crl['cert']) == 0)) :
?> ?>
<tr> <tr>
<td colspan="4"> <td colspan="4">
...@@ -521,7 +530,7 @@ elseif ($act == "edit") : ...@@ -521,7 +530,7 @@ elseif ($act == "edit") :
// Map Certs to CAs in one pass // Map Certs to CAs in one pass
$ca_certs = array(); $ca_certs = array();
foreach ($a_cert as $cert) { foreach ($a_cert as $cert) {
if ($cert['caref'] == $crl['caref']) { if (isset($cert['caref']) && isset($crl['caref']) && $cert['caref'] == $crl['caref']) {
$ca_certs[] = $cert; $ca_certs[] = $cert;
} }
} }
...@@ -650,7 +659,7 @@ endif; ?> ...@@ -650,7 +659,7 @@ endif; ?>
</tr> </tr>
<?php <?php
if (is_array($ca_crl_map[$ca['refid']])) : if (isset($ca_crl_map[$ca['refid']]) && is_array($ca_crl_map[$ca['refid']])) :
foreach ($ca_crl_map[$ca['refid']] as $crl) : foreach ($ca_crl_map[$ca['refid']] as $crl) :
$tmpcrl = lookup_crl($crl); $tmpcrl = lookup_crl($crl);
$internal = is_crl_internal($tmpcrl); $internal = is_crl_internal($tmpcrl);
...@@ -659,7 +668,7 @@ endif; ?> ...@@ -659,7 +668,7 @@ endif; ?>
<tr> <tr>
<td class="listlr"><?php echo $tmpcrl['descr']; ?></td> <td class="listlr"><?php echo $tmpcrl['descr']; ?></td>
<td class="listr"><?php echo ($internal) ? "YES" : "NO"; ?></td> <td class="listr"><?php echo ($internal) ? "YES" : "NO"; ?></td>
<td class="listr"><?php echo ($internal) ? count($tmpcrl['cert']) : "Unknown (imported)"; ?></td> <td class="listr"><?php echo ($internal) ? (isset($tmpcrl['cert']) && count($tmpcrl['cert'])) : "Unknown (imported)"; ?></td>
<td class="listr"><?php echo ($inuse) ? "YES" : "NO"; ?></td> <td class="listr"><?php echo ($inuse) ? "YES" : "NO"; ?></td>
<td valign="middle" class="list nowrap"> <td valign="middle" class="list nowrap">
<a href="system_crlmanager.php?act=exp&amp;id=<?=$tmpcrl['refid'];?>" class="btn btn-default btn-xs"> <a href="system_crlmanager.php?act=exp&amp;id=<?=$tmpcrl['refid'];?>" class="btn btn-default btn-xs">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment