]> dxcluster.org Git - spider.git/commitdiff
fiddle with 8 bit characters, start to check everything more rigourously
authorminima <minima>
Sun, 30 Jul 2000 22:08:02 +0000 (22:08 +0000)
committerminima <minima>
Sun, 30 Jul 2000 22:08:02 +0000 (22:08 +0000)
Changes
perl/DXProt.pm
perl/Msg.pm
src/client.c

diff --git a/Changes b/Changes
index f922a1e89de13bacbe0c57ba99dabedce07bd487..968fc9ef20e1928b0d2c24f99691fbfa8c4ee4a2 100644 (file)
--- a/Changes
+++ b/Changes
@@ -8,6 +8,8 @@
 7. stopped a few more things being done by rcmd (eg send, talk, ann, dx)
 8. tidied up the talking a bit more.
 9. Increase default hop counts all round.
+10. Adjust hex encoding so that 8 bit characters should now go thru
+11. check more of the essential protocol fields for 8 bit characters.
 29Jul00=======================================================================
 1. added forward/latlong which will forward ALL the users that have a latitude
 and longitude set on them to one or more locally connected nodes - with a hop
index 90506ed4df9ee6c44ea80e115fe0abef9b6c38bc..310416e8dfda883713b863a969a080867e2d55a6 100644 (file)
@@ -158,8 +158,8 @@ sub normal
        return unless $pcno;
        return if $pcno < 10 || $pcno > 99;
 
-       # dump bad protocol messages unless it is a PC29
-       if ($line =~ /\%[0-9A-F][0-9A-F]/o && $pcno != 29) {
+       # dump bad protocol messages
+       if ($line =~ /\%[01][0-9A-F]/) {
                dbg('chan', "CORRUPT protocol message - dumped");
                return;
        }
@@ -175,16 +175,24 @@ sub normal
  SWITCH: {
                if ($pcno == 10) {              # incoming talk
                        
+                       unless (is_callsign($field[1]) && is_callsign($field[2]) && is_callsign($field[6])) {
+                               dbg('chan', "Corrupt talk, rejected");
+                               return;
+                       }
                        # is it for me or one of mine?
-                       my $call = ($field[5] gt ' ') ? $field[5] : $field[2];
-                       if ($call eq $main::mycall || grep $_ eq $call, DXChannel::get_all_user_calls()) {
-                               
-                               # yes, it is
-                               my $text = unpad($field[3]);
-                               Log('talk', $call, $field[1], $field[6], $text);
-                               $call = $main::myalias if $call eq $main::mycall;
-                               my $ref = DXChannel->get($call);
-                               $ref->send("$call de $field[1]: $text") if $ref && $ref->{talk};
+                       my ($to, $via, $call, $dxchan);
+                       if ($field[5] gt ' ') {
+                               $call = $via = $field[2];
+                               $to = $field[5];
+                               unless (is_callsign($to)) {
+                                       dbg('chan', "Corrupt talk, rejected");
+                                       return;
+                               }
+                       } else {
+                               $call = $to = $field[2];
+                       }
+                       if ($dxchan = DXChannel->get($call)) {
+                               $dxchan->talk($field[1], $to, $via, $field[3]);
                        } else {
                                $self->route($field[2], $line); # relay it on its way
                        }
@@ -193,6 +201,16 @@ sub normal
                
                if ($pcno == 11 || $pcno == 26) { # dx spot
 
+                       # are any of the callsign fields invalid?
+            unless ($field[2] !~ m/[^A-Z0-9\-\/]/ && is_callsign($field[6]) && is_callsign($field[7])) {
+                               dbg('chan', "Spot contains lower case callsigns or blanks, rejected");
+                               return;
+                       }
+            if ($field[1] =~ m/[^0-9\.]/) {
+                               dbg('chan', "Spot frequency not numeric, rejected");
+                               return;
+                       }
+
                        # route 'foreign' pc26s 
                        if ($pcno == 26) {
                                if ($field[7] ne $main::mycall) {
@@ -220,16 +238,6 @@ sub normal
                                dbg('chan', "Bad DX spot, ignored");
                                return;
                        }
-
-                       # are any of the callsign fields invalid?
-            if ($field[2] =~ m/[^A-Z0-9\-\/]/ || $field[6] =~ m/[^A-Z0-9\-]/ || $field[7] =~ m/[^A-Z0-9\-]/) {
-                               dbg('chan', "Spot contains lower case callsigns or blanks, rejected");
-                               return;
-                       }
-            if ($field[1] =~ m/[^0-9\.]/) {
-                               dbg('chan', "Spot frequency not numeric, rejected");
-                               return;
-                       }
                        
                        # do some de-duping
                        $field[5] =~ s/^\s+//;      # take any leading blanks off
@@ -307,6 +315,11 @@ sub normal
                }
                
                if ($pcno == 12) {              # announces
+                       unless (is_callsign($field[1]) && is_callsign($field[2]) && is_callsign($field[5])) {
+                               dbg('chan', "Corrupt announce, rejected");
+                               return;
+                       }
+
                        # announce duplicate checking
                        $field[3] =~ s/^\s+//;  # remove leading blanks
                        if (AnnTalk::dup($field[1], $field[2], $field[3])) {
@@ -1413,6 +1426,12 @@ sub disconnect
        $self->SUPER::disconnect;
 }
 
+# check that a field only has callsign characters in it
+sub is_callsign
+{
+       return $_[0] !~ /[^A-Z0-9\-]/
+}
+
 # 
 # send a talk message to this thingy
 #
index f5704a81e46eb237403f695383e7bd3307770dbf..0af6791156f92b8c8e9698707fca33202ff3ae18 100644 (file)
@@ -237,7 +237,7 @@ FINISH:
 
        while (@lines){
                $msg = shift @lines;
-               $msg =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+               $msg =~ s/%([2-9A-F][0-9A-F])/chr(hex($1))/eg;
                &{$conn->{rcvd_notification_proc}}($conn, $msg, $!);
                $! = 0;
        }
index 0b41241e9a4d945b16cd0ea3103972efe4bec6e6..c330536bf3a15e6c52ed21987692a55a2258a95a 100644 (file)
@@ -448,12 +448,10 @@ int fcb_handler(sel_t *sp, int in, int out, int err)
 
                                case 1:
                                        mp->state = 2;
-                                       if (ch >= '0' && ch <= '9') 
+                                       if (ch >= '2' && ch <= '9') 
                                                c = (ch - '0') << 4;
                                        else if (ch >= 'A' && ch <= 'F')
                                                c = (ch - 'A' + 10) << 4;
-                                       else if (ch >= 'a' && ch <= 'a')
-                                               c = (ch - 'a' + 10) << 4;
                                        else {
                                                dbg(DMSG, "Illegal hex char (%c) received in state %d", ch, mp->state);
                                                mp->inp = mp->data;
@@ -466,8 +464,6 @@ int fcb_handler(sel_t *sp, int in, int out, int err)
                                                *mp->inp++ = c | (ch - '0');
                                        else if (ch >= 'A' && ch <= 'F')
                                                *mp->inp++ = c | (ch - 'A' + 10);
-                                       else if (ch >= 'a' && ch <= 'a')
-                                               *mp->inp++ = c | (ch - 'a' + 10);
                                        else {
                                                dbg(DMSG, "Illegal hex char (%c) received in state %d", ch, mp->state);
                                                mp->inp = mp->data;