From 3f83e3c3106b558c047e4e0e840bc26d9b80d993 Mon Sep 17 00:00:00 2001 From: Digimer Date: Fri, 18 Jan 2019 03:51:09 -0500 Subject: [PATCH] * Fixed the problem with rendering the webUI... The recursive loop counter was set to 1000, and that was triggering when reading a file longer than 1000 lines. Pushed the counter up to 500000 to prevent this in the future, but still allow infinite loops to exit before too long. * Added 'CGI::Carp "fatalsToBrowser"' to striker to make error handling better, and print out the HTML header when the loop detector fires in a browser. * Updated System->check_if_configured() return '0' instead of an empty string when not configured. * Added the 'test' parameter for debugging to Template->get(). Signed-off-by: Digimer --- Anvil/Tools/Log.pm | 3 ++- Anvil/Tools/System.pm | 2 ++ Anvil/Tools/Template.pm | 1 + cgi-bin/striker | 16 ++++++---------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Anvil/Tools/Log.pm b/Anvil/Tools/Log.pm index cc19af57..be511acc 100644 --- a/Anvil/Tools/Log.pm +++ b/Anvil/Tools/Log.pm @@ -251,7 +251,8 @@ sub entry $anvil->data->{loop}{count} = 0 if not defined $anvil->data->{loop}{count}; $anvil->data->{loop}{count}++; print $THIS_FILE." ".__LINE__."; [ Debug ] - level: [".$level."], defaults::log::level: [".$anvil->data->{defaults}{'log'}{level}."], logging secure? [".$anvil->Log->secure."], loop::count: [".$anvil->data->{loop}{count}."]\n" if $test; - if ($anvil->data->{loop}{count} > 1000) + # The counter needs to be longer than any conceivable file line count we might read. + if ($anvil->data->{loop}{count} > 500000) { if ($anvil->environment eq "html") { diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index ec4b9854..ef7ab3ff 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -494,6 +494,8 @@ sub check_if_configured modified_date => $modified_date, }}); + $configured = 0 if not defined $configured; + $configured = 0 if $configured eq ""; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { configured => $configured }}); return($configured); } diff --git a/Anvil/Tools/Template.pm b/Anvil/Tools/Template.pm index 12693105..5b10be79 100644 --- a/Anvil/Tools/Template.pm +++ b/Anvil/Tools/Template.pm @@ -121,6 +121,7 @@ sub get my $parameter = shift; my $anvil = $self->parent; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + my $test = defined $parameter->{test} ? $parameter->{test} : 0; my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $language = defined $parameter->{language} ? $parameter->{language} : $anvil->Words->language({debug => $debug}); diff --git a/cgi-bin/striker b/cgi-bin/striker index a7b3a3b2..04d8ffa2 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -13,6 +13,7 @@ use warnings; use Anvil::Tools; use Data::Dumper; use NetAddr::IP; +use CGI::Carp "fatalsToBrowser"; # Turn off buffering $| = 1; @@ -24,16 +25,11 @@ if (($running_directory =~ /^\./) && ($ENV{PWD})) $running_directory =~ s/^\./$ENV{PWD}/; } -my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1}); +my $anvil = Anvil::Tools->new(); +$anvil->Log->level({set => 2}); ### NOTE: We'll print the headers only when we need to. If we print them here, it will block cookies being set. - -# Set the log level to 2. Setting 3 slows he program down a LOT. - -# Read the config and then connect to the database. -$anvil->Storage->read_config(); - -### Setup some variables. +# Setup some variables. $anvil->data->{skin}{url} = $anvil->data->{path}{urls}{skins}."/".$anvil->Template->skin; $anvil->data->{form}{body} = ""; $anvil->data->{form}{error_massage} = ""; @@ -65,10 +61,10 @@ if (not $anvil->data->{sys}{database}{connections}) # If any jobs are pending/running, show the "unavailable" option. my $configured = $anvil->System->check_if_configured; -$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }}); my $available = $configured ? check_availability($anvil) : 0; -$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {available => $available }}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {available => $available }}); if (not $configured) { # If there is no user account yet, then the system is new and needs to be reconfigured.