From: Jean-Marc Pigeon (Delson) Date: Sat, 5 Jul 2025 23:50:44 +0000 (-0400) Subject: Adding RSPTYP structure X-Git-Tag: tag-0.12~22 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=5f9a0eae7f4203c3e0caa26132cc07ea430f5b85;p=jmp%2Fmailleur Adding RSPTYP structure --- diff --git a/lib/unidig.c b/lib/unidig.c index cd14e10..064d019 100644 --- a/lib/unidig.c +++ b/lib/unidig.c @@ -13,6 +13,31 @@ #include "subcnv.h" #include "unidig.h" +/* + * +*/ +/********************************************************/ +/* */ +/* 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; +} /* * */ diff --git a/lib/unidig.h b/lib/unidig.h index c040a54..9d7eef1 100644 --- a/lib/unidig.h +++ b/lib/unidig.h @@ -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); diff --git a/tools/Makefile b/tools/Makefile index 145a321..da59d8b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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) diff --git a/tools/digmd5.c b/tools/digmd5.c index 6b77d86..5958bca 100644 --- a/tools/digmd5.c +++ b/tools/digmd5.c @@ -13,6 +13,7 @@ #include #include +#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;