]> SAFE projects GIT repository - jmp/mailleur/commitdiff
chkip6 test are now working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 19 Aug 2024 08:59:29 +0000 (04:59 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Mon, 19 Aug 2024 08:59:29 +0000 (04:59 -0400)
app/chkdns.c
lib/gesspf.c
lib/subafn.c
lib/subrou.c

index 750bbcaa96b80a4de1f088e4b316a9167af9fa8a..8bc801c8f90e0c000535f2d5cdc4ee933fc74484 100644 (file)
@@ -36,19 +36,16 @@ char *ptr;
 
 //removing head space
 while (line[0]==' ')
-  (void) memmove(line,line+1,strlen(line+1));
+  (void) memmove(line,line+1,strlen(line+1)+1);
 //Extracting keyword
 (void) strcpy(keyword,line);
 if ((ptr=strchr(keyword,' '))!=(char *)0)
   *ptr='\000';
-if ((ptr=strchr(keyword,'\n'))!=(char *)0)
-  *ptr='\000';
-
 //cleaning line
 ptr=line+strlen(keyword);
-(void) memmove(line,ptr,strlen(ptr));
+(void) memmove(line,ptr,strlen(ptr)+1);
 while (line[0]==' ') 
-  (void) memmove(line,line+1,strlen(line+1));
+  (void) memmove(line,line+1,strlen(line+1)+1);
 return strlen(keyword);
 }
 /*
@@ -92,6 +89,8 @@ static int scanline(char *filename,FILE *fichier)
 {
 #define MAX     300
 
+static  char *noneed="#\n\r";
+
 int status;
 int num;
 char line[MAX];
@@ -104,14 +103,11 @@ num=0;
 while (fgets(line,sizeof(line),fichier)!=(char *)0) {
   char *ptr;
 
-  (void) printf("JMPDBG line=<%s>\n",line);
   num++;
-  if ((ptr=strchr(line,'\n'))!=(char *)0)
-    *ptr='\000';
-  if ((ptr=strchr(line,'\r'))!=(char *)0)
-    *ptr='\000';
-  if ((ptr=strchr(line,'#'))!=(char *)0)
-    *ptr='\000';
+  for (int i=0;i<strlen(noneed);i++) {
+    if ((ptr=strchr(line,noneed[i]))!=(char *)0)
+      *ptr='\000';
+    }
   if (strlen(line)==0)
     continue;
   //replacing HT by space
index 224394ae2719f3d0a056c6a813d53db88e724a5e..f2faf17e782b369998c13fd19db9e15c39149cf9 100644 (file)
@@ -190,7 +190,8 @@ while (proceed==true) {
         }
       break;
     case 1      :       //getting the list of MX for mxdomain
-      (void) printf("JMPDBG, checkaddr got <%s> cidr='%d'",addrdom,cidr);
+      (void) printf("JMPDBG, checkaddr got <%s> ip<%s> cidr='%d'\n",
+                            addrdom,afnnum->strnumip,cidr);
       break;
     default     :       //SAFE guard
       proceed=false;
@@ -279,8 +280,6 @@ while (proceed==true) {
                              OPEP,mxlist[i]->mxname);
             continue;
             }
-          (void) printf("JMPDBG addr=<%s> peer=<%s> cidr='%d'\n",
-                         addrnum->strnumip,afnnum->strnumip,cidr);
           switch (afn_cmpipnum(addrnum,afnnum,cidr)) {
             case false  :       //not found
               break;
@@ -407,7 +406,6 @@ _Bool proceed;
 
 spf=spf_neutral;
 locspf=spf_pass;
-(void) printf("JMPDBG checkseq seq=<%s>\n",seq);
 phase=0;
 proceed=true;
 while (proceed==true) {
@@ -443,7 +441,6 @@ while (proceed==true) {
         case mch_mx             :       //This is a MX refrence
           if (checkmx(domain,afnnum,seq)==true)
             spf=locspf;
-          (void) printf("JMPDBG checkmsx status='%s'\n",spf_spfASCII(spf));
           break;
         case mch_ip4            :       //This is IPV4 number
         case mch_ip6            :       //This is IPV6 number
@@ -477,7 +474,6 @@ while (proceed==true) {
     }
   phase++;
   }
-(void) printf("JMPDBG checkseq status='%s'\n",spf_spfASCII(spf));
 return spf;
 
 #undef  OPEP
index 2c0fc158955ee4291e9fb9cbd52e5ba34d6ed5f7..35d2458eed5837825588a04064f57261cdf25bc3 100644 (file)
@@ -36,8 +36,6 @@ areequal=false;
 if (mask>128)
   mask=128;
 maskbyt=mask/8;
-(void) printf("JMPDBG mask='%d' compare <%s> et <%s>",
-               mask,ipnum1->strnumip,ipnum2->strnumip);
 if (memcmp(ipnum1->ip,ipnum2->ip,maskbyt)==0) {
   areequal=true;
   mask%=8;
@@ -53,7 +51,6 @@ if (memcmp(ipnum1->ip,ipnum2->ip,maskbyt)==0) {
       areequal=false;
     }
   }
-(void) printf("res='%d'\n", areequal); //JMPDBG
 return areequal;
 }
 /*
@@ -230,13 +227,33 @@ while (proceed==true) {
        cleanipstr=ZIPV4;
       break;
     case 4     :       //lets convert it
-      if (inet_pton(afnnum->afntype,cleanipstr,afnnum->ip)<=0)  {
-       afnnum=afn_freeipnum(afnnum);
-        phase=999;      //no need to go further
+      switch (inet_pton(afnnum->afntype,cleanipstr,afnnum->ip)) {
+        case  1         :       //success
+          break;
+        case  0         :       //Invalid IP number
+          (void) fprintf(stderr,"Unable to convert IP <%s> (Invalid IP number)\n",
+                                cleanipstr);
+         afnnum=afn_freeipnum(afnnum);
+          phase=999;            //no need to go further
+          break;
+        case -1         :       //Invalid IP number
+          (void) fprintf(stderr,"Unable to convert IP <%s> (error=<%s>)\n",
+                                cleanipstr,strerror(errno));
+         afnnum=afn_freeipnum(afnnum);
+          phase=999;            //no need to go further
+          break;
+        default         :       //Unexpected Result
+          (void) fprintf(stderr,"Unexpected status to convert IP <%s>  "
+                                "(error=<%s> BUG!?)\n",
+                                cleanipstr,strerror(errno));
+         afnnum=afn_freeipnum(afnnum);
+          phase=999;            //no need to go further
         }
       break;
     case 5     :       //lets convert it
       afnnum->strnumip=afn_getstrip(afnnum);
+      //(void) printf("JMPDBG <%s> -> converted to <%s>\n",
+                     //cleanipstr,afnnum->strnumip);
       break;
     default    :       /*SAFE guard            */
       proceed=false;
index f30e326d3fbd8f10c47b871b1730213cca6e7fc0..05c0d9e187b1732e3b9254fb543942fc6e6aaa1d 100644 (file)
@@ -21,7 +21,7 @@
 
 //version definition 
 #define VERSION "0.4.2"
-#define RELEASE "24"
+#define RELEASE "25"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level