]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adding RSPTYP structure
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 5 Jul 2025 23:50:44 +0000 (19:50 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 5 Jul 2025 23:50:44 +0000 (19:50 -0400)
lib/unidig.c
lib/unidig.h
tools/Makefile
tools/digmd5.c

index cd14e109e691f3034ac99ef0328f6e50da87f4ff..064d019e1c0fe1264ce2332110167c67176c6726 100644 (file)
 #include       "subcnv.h"
 #include       "unidig.h"
 
+/*
+ * \f
+*/
+/********************************************************/
+/*                                                      */
+/*      Procedure to free all memroy used by a response */
+/*      type structure.                                 */
+/*                                                      */
+/********************************************************/
+PUBLIC RSPTYP *dig_freeresp(RSPTYP *resp)
+
+{
+if (resp!=(RSPTYP *)0) {
+  resp->response=rou_freestr(resp->response);
+  resp->qpop=rou_freestr(resp->qpop);
+  resp->nc=rou_freestr(resp->nc);
+  resp->cnonce=rou_freestr(resp->cnonce);
+  resp->nonce=rou_freestr(resp->nonce);
+  resp->realm=rou_freestr(resp->realm);
+  resp->username=rou_freestr(resp->username);
+  (void) free(resp);
+  resp=(RSPTYP *)0;
+  }
+return resp;
+}
 /*
  * \f
 */
index c040a54d03d3a4df0eaf000d1b9874c8d749dafd..9d7eef15acd377ea4b2f2f62bddd91b438312753 100644 (file)
@@ -8,9 +8,22 @@
 #ifndef        UNIDIG
 #define UNIDIG
 
+typedef struct  {       //DIGEST-MD5 challange response structure
+        char *username; //username requesting authentication
+        char *realm;    //Challenge realm
+        char *nonce;    //server nonce
+        char *cnonce;   //client nonce
+        char *nc;       //nonce count
+        char *qpop;     //protection quality (authentication)
+        char *response; //Challenge md5 response
+        }RSPTYP;
+
 //MD5 hashing result
 typedef unsigned char MD5TYP[17];
 
+//procedure to free the response structure
+extern RSPTYP *dig_freeresp(RSPTYP *resp);
+
 //procedure to convert a string to a 128 Bit sequence
 //as a string
 extern MD5TYP *dig_hashmd5(unsigned char *seq);
index 145a321cf6427ea2b090253a6c88fe5de23b5d36..da59d8b01d73481c41da873fc328a573924d616b 100644 (file)
@@ -45,7 +45,14 @@ LIBS =       $(LIBMAIL)                      \
 tstmd5 :  digmd5
           @ ./digmd5 xxx $(BASE64)
 
-dbgmd5 :  debug
+VALKIND        =  "definite,possible,indirect"
+valmd5 :  digmd5
+          @ valgrind                           \
+               --leak-check=full               \
+               --show-leak-kinds=$(VALKIND)    \
+               ./digmd5 xxx $(BASE64)
+
+dbgmd5 :  digmd5
           @ gdb                                \
                        --args                  \
                        ./digmd5 xxx $(BASE64)
index 6b77d86378292d95179e6d144e34ad0f6d4fdc86..5958bca28378853e22b9c30fa55c83ef59eb039d 100644 (file)
@@ -13,6 +13,7 @@
 #include       <string.h>
 #include       <unistd.h>
 
+#include       "subcnv.h"
 #include       "subrou.h"
 #include       "unidig.h"
 #include       "unipar.h"
@@ -33,16 +34,18 @@ static int chkresponse(int argc,char *argv[])
 #define OPEP    "digmd5.c:chkresponse,"
 
 int status;
+char *cleartext;
 int phase;
 _Bool proceed;
 
 status=-1;
+cleartext=cnv_getb64(argv[1]);
 phase=0;
-proceed=true;
+proceed=(cleartext!=(char *)0);
 while (proceed==true) {
   switch (phase) {
     case 0      :       //
-      (void) rou_alert(0,"%s argv[1]=<%s>",OPEP,argv[1]);
+      (void) rou_alert(0,"%s cleartext=<%s>",OPEP,cleartext);
       break;
     default     :       //SAFE Guard
       proceed=false;
@@ -50,7 +53,9 @@ while (proceed==true) {
     }
   phase++;
   }
+cleartext=rou_freestr(cleartext);
 return status;
+
 #undef  OPEP
 }
 /*
@@ -99,6 +104,11 @@ while (proceed==true) {
     case 3      :       //doing main task
       (void) chkresponse(params->argc,params->argv);
       break;
+    case 4      :       //main task completed
+      (void) prc_cleantitle();
+      params=par_freeparams(params);
+      (void) rou_modesubrou(false);
+      break;
     default     :       //end of task
       proceed=false;
       break;