From 72e9dcbade3fdb51d9291a2856ca1cc998241f9b Mon Sep 17 00:00:00 2001 From: djk Date: Sun, 18 Jun 2000 00:31:17 +0000 Subject: [PATCH] Hardened up the cluster->client link in the cluster software so that rubbish on port 27754 doesn't (usually) crash the cluster. --- Changes | 2 ++ perl/DXChannel.pm | 20 ++++++++++++++++++++ perl/cluster.pl | 11 +++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 32d3844b..a71063c4 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ 3. added update_sysop.pl which cleans out all previous versions of the sysops information from the user database and recreates it with that in DXVars.pm 4. Added node type to links and who +5. Hardened up the cluster->client link in the cluster software so that +rubbish on port 27754 doesn't (usually) crash the cluster. 14Jun00======================================================================= 1. fixed sh/node crash 2. fixed RTT in who.pl diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 3637b762..df74bfc8 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -436,6 +436,26 @@ sub field_prompt return $valid{$ele}; } +# take a standard input message and decode it into its standard parts +sub decode_input +{ + my $dxchan = shift; + my $data = shift; + my ($sort, $call, $line) = $data =~ /^([A-Z])([A-Z1-9\-]{3,9})\|(.*)$/; + + my $chcall = (ref $dxchan) ? $dxchan->call : "UN.KNOWN"; + + # the above regexp must work + if (!defined $sort || !defined $call || !defined $line || + (ref $dxchan && $call ne $chcall)) { + $data =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg; + dbg('chan', "DUFF Line from $chcall: $data"); + return (); + } + + return ($sort, $call, $line); +} + no strict; sub AUTOLOAD { diff --git a/perl/cluster.pl b/perl/cluster.pl index d026edd6..4da018b0 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -120,7 +120,8 @@ sub rec # set up the basic channel info - this needs a bit more thought - there is duplication here if (!defined $dxchan) { - my ($sort, $call, $line) = $msg =~ /^(\w)(\S+)\|(.*)$/; + my ($sort, $call, $line) = DXChannel::decode_input(0, $msg); + return unless defined $sort; # is there one already connected to me - locally? my $user = DXUser->get($call); @@ -246,17 +247,15 @@ sub process_inqueue my $data = $self->{data}; my $dxchan = $self->{dxchan}; - my ($sort, $call, $line) = $data =~ /^(\w)([^\|]+)\|(.*)$/; my $error; - - # the above regexp must work - return unless ($sort && $call && $line); + my ($sort, $call, $line) = DXChannel::decode_input($dxchan, $data); + return unless defined $sort; # translate any crappy characters into hex characters if ($line =~ /[\x00-\x06\x08\x0a-\x1f\x7f-\xff]/o) { $line =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg; } - + # do the really sexy console interface bit! (Who is going to do the TK interface then?) dbg('chan', "<- $sort $call $line\n") unless $sort eq 'D'; -- 2.34.1