From aaf98478dc930b9d337c85c41316a926046d7ae2 Mon Sep 17 00:00:00 2001 From: minima Date: Mon, 1 Oct 2001 11:56:35 +0000 Subject: [PATCH] change the looping protoection for PC16/17/19/21 and also be more rigorous in who we accept which PC16/17/21's from. --- Changes | 2 ++ perl/DXLog.pm | 3 +-- perl/DXMsg.pm | 4 +-- perl/DXProt.pm | 68 ++++++++++++++++++++++++++++---------------------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Changes b/Changes index 0ea38112..487d3467 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ 01Oct01======================================================================= 1. made login info not the default +2. change the looping protoection for PC16/17/19/21 and also be more rigorous +in who we accept which PC16/17/21's from. 30Sep01======================================================================= 1. made some small bug fixes in rspf checking and also messages. 23Sep01======================================================================= diff --git a/perl/DXLog.pm b/perl/DXLog.pm index c13e26c1..60763085 100644 --- a/perl/DXLog.pm +++ b/perl/DXLog.pm @@ -92,14 +92,13 @@ sub open $mode = 'r' if !$mode; $self->{mode} = $mode; + $self->{jdate} = $jdate; my $fh = new IO::File $self->{fn}, $mode, 0666; return undef if !$fh; $fh->autoflush(1) if $mode ne 'r'; # make it autoflushing if writable $self->{fh} = $fh; - $self->{jdate} = $jdate; - # DXDebug::dbg("opening $self->{fn}\n") if isdbg("dxlog"); return $self->{fh}; diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index fefcc2fa..45de0f9f 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -281,8 +281,8 @@ sub process if ($ref->{subject} eq $m->{subject} && $ref->{t} == $m->{t} && $ref->{from} eq $m->{from} && $ref->{to} eq $m->{to}) { $ref->stop_msg($self->call); my $msgno = $m->{msgno}; - dbg("duplicate message from $ref->{from} -> $ref->{to} to $msgno") if isdbg('msg'); - Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to $msgno"); + dbg("duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno") if isdbg('msg'); + Log('msg', "duplicate message from $ref->{from} -> $ref->{to} to msg: $msgno"); return; } } diff --git a/perl/DXProt.pm b/perl/DXProt.pm index e6380b56..f8e2b4b9 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -578,6 +578,11 @@ sub normal if ($pcno == 16) { # add a user + if (eph_dup($line)) { + dbg("PCPROT: dup PC16 detected") if isdbg('chanerr'); + return; + } + # general checks my $dxchan; my $ncall = $field[1]; @@ -587,17 +592,17 @@ sub normal dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr'); return; } - $dxchan = DXChannel->get($ncall); - if ($dxchan && $dxchan ne $self) { - dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr'); - return; - } my $parent = Route::Node::get($ncall); unless ($parent) { dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr'); return; } - + $dxchan = $parent->dxchan; + if ($dxchan && $dxchan ne $self) { + dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr'); + return; + } + # input filter if required return unless $self->in_filter_route($parent); @@ -642,11 +647,6 @@ sub normal $user->lastin($main::systime) unless DXChannel->get($call); $user->put; } - - if (eph_dup($line)) { - dbg("PCPROT: dup PC16 detected") if isdbg('chanerr'); - return; - } # queue up any messages (look for privates only) DXMsg::queue_msg(1) if $self->state eq 'normal'; @@ -660,17 +660,17 @@ sub normal my $ncall = $field[2]; my $ucall = $field[1]; + if (eph_dup($line)) { + dbg("PCPROT: dup PC17 detected") if isdbg('chanerr'); + return; + } + eph_del_regex("^PC16.*$ncall.*$ucall"); if ($ncall eq $main::mycall) { dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr'); return; } - $dxchan = DXChannel->get($ncall); - if ($dxchan && $dxchan ne $self) { - dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr'); - return; - } my $uref = Route::User::get($ucall); unless ($uref) { @@ -683,16 +683,17 @@ sub normal return; } + $dxchan = $parent->dxchan; + if ($dxchan && $dxchan ne $self) { + dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr'); + return; + } + # input filter if required return unless $self->in_filter_route($parent); my @rout = $parent->del_user($uref); - if (eph_dup($line)) { - dbg("PCPROT: dup PC17 detected") if isdbg('chanerr'); - return; - } - $self->route_pc17($parent, @rout) if @rout; return; } @@ -713,6 +714,11 @@ sub normal my $i; my $newline = "PC19^"; + if (eph_dup($line)) { + dbg("PCPROT: dup PC19 detected") if isdbg('chanerr'); + return; + } + # new routing list my @rout; my $parent = Route::Node::get($self->{call}); @@ -789,10 +795,6 @@ sub normal $user->put; } - if (eph_dup($line)) { - dbg("PCPROT: dup PC19 detected") if isdbg('chanerr'); - return; - } $self->route_pc19(@rout) if @rout; return; @@ -809,6 +811,11 @@ sub normal if ($pcno == 21) { # delete a cluster from the list my $call = uc $field[1]; + if (eph_dup($line)) { + dbg("PCPROT: dup PC21 detected") if isdbg('chanerr'); + return; + } + eph_del_regex("^PC1[79].*$call"); my @rout; @@ -820,6 +827,12 @@ sub normal } my $node = Route::Node::get($call); if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me! + my $dxchan = $node->dxchan; + if ($dxchan && $dxchan ne $self) { + dbg("PCPROT: PC21 from $self->{call} trying to alter locally connected $call, ignored!") if isdbg('chanerr'); + return; + } + if ($call eq $self->{call}) { dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr'); return; @@ -837,11 +850,6 @@ sub normal return; } - if (eph_dup($line)) { - dbg("PCPROT: dup PC21 detected") if isdbg('chanerr'); - return; - } - $self->route_pc21(@rout) if @rout; return; } -- 2.34.1