From: Dirk Koopman Date: Fri, 29 Feb 2008 22:47:43 +0000 (+0000) Subject: Fix crash on sending an invalid rcmd X-Git-Tag: 1.55~5 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=82aac01bdf511916e98a71873950fb98a54440a0;p=spider.git Fix crash on sending an invalid rcmd --- diff --git a/Changes b/Changes index 8e15eddd..6faf3672 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +29Feb08======================================================================= +1. Fix crash on rcmd of an invalid command. 25Feb08======================================================================= 1. Arrange for AGWMsg to retry connection either if the AGW engine isn't loaded on startup or it disappears for some reason and restarts. diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 7d340a61..fcc230aa 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -35,7 +35,7 @@ use Prefix; use Route; use strict; -use vars qw(%channels %valid @ISA $count); +use vars qw(%channels %valid @ISA $count $maxerrors); %channels = (); $count = 0; @@ -125,6 +125,8 @@ $count = 0; next_pc92_keepalive => '9,Next PC92 KeepAlive,atime', ); +$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection + # object destruction sub DESTROY { @@ -177,6 +179,22 @@ sub alloc return $channels{$call} = $self; } +# count errors and disconnect if too many +# this has to be here because it can come from rcmd (DXProt) as +# well as DXCommandmode. +sub _error_out +{ + my $self = shift; + my $e = shift; + if (++$self->{errors} > $maxerrors) { + $self->send($self->msg('e26')); + $self->disconnect; + return (); + } else { + return ($self->msg($e)); + } +} + # rebless this channel as something else sub rebless { diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 0a42e510..cdde9a20 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -39,7 +39,7 @@ use VE7CC; use DXXml; use strict; -use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug +use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug $maxbadcount $msgpolltime $default_pagelth $cmdimportdir); %Cache = (); # cache of dynamically loaded routine's mod times @@ -47,7 +47,6 @@ use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %notheresl $errstr = (); # error string from eval %aliases = (); # aliases for (parts of) commands $scriptbase = "$main::root/scripts"; # the place where all users start scripts go -$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection $maxbadcount = 3; # no of bad words allowed before disconnection $msgpolltime = 3600; # the time between polls for new messages $cmdimportdir = "$main::root/cmd_import"; # the base directory for importing command scripts @@ -485,19 +484,6 @@ sub send_ans } } -sub _error_out -{ - my $self = shift; - my $e = shift; - if (++$self->{errors} > $maxerrors) { - $self->send($self->msg('e26')); - $self->disconnect; - return (); - } else { - return ($self->msg($e)); - } -} - # # this is the thing that runs the command, it is done like this for the # benefit of remote command execution @@ -569,7 +555,7 @@ sub run_cmd if ($ok) { delete $self->{errors}; } else { - if (++$self->{errors} > $maxerrors) { + if (++$self->{errors} > $DXChannel::maxerrors) { $self->send($self->msg('e26')); $self->disconnect; return (); diff --git a/perl/Version.pm b/perl/Version.pm index c99aae34..8441ebfa 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '214'; +$build = '215'; 1;