From 7b2b76b2f8b0b8868ace3deb7d9e9e5348aac563 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Thu, 3 Jul 2025 21:47:26 -0400 Subject: [PATCH] Improved incoming character overflow incoming from remote --- Makefile.dbg | 2 ++ lib/devsoc.c | 23 ++++++++++++++++------- lib/lvleml.c | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile.dbg b/Makefile.dbg index 4c30730..e130466 100644 --- a/Makefile.dbg +++ b/Makefile.dbg @@ -35,6 +35,8 @@ gorcvr : clean debug $(EMLPAR)$(TESTITER) digest : clean debug + gdb \ + --args \ \ ./bin/receiver \ -f \ diff --git a/lib/devsoc.c b/lib/devsoc.c index 379511b..9be5479 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -24,7 +24,8 @@ #include "unitls.h" #include "devsoc.h" -#define MXCARIN 200 //maximun number of char within carpile +#define MXCARIN 1200 //maximun number of char within carpile + //full line sould be more than 998 char typedef struct { PROTYP proto; //Connexion protocol type @@ -359,7 +360,7 @@ while (proceed==true) { /* Procedure to extract next line from the socket */ /* incoming pile. */ /* Return the number of character, zero if the */ -/* line is empty, -1 if now char available. */ +/* line is empty, -1 if no char are available. */ /* */ /********************************************************/ static int doextract(SOCTYP *soc,char **lineptr) @@ -384,26 +385,34 @@ while (proceed==true) { if (soc->carin==0) phase=999; //No char,no need to check for line break; - case 1 : //Do we have a CRLF + case 1 : //do we have a buffer full; + if (soc->carin>=(soc->maxcarin)-1) { + //Overload! trying to overcome by extending carpile an adding an EOL + soc->carpile=(char *)realloc(soc->carpile,(soc->carin+5)*sizeof(char)); + (void) strcat(soc->carpile,soc->EOL); + } + break; + case 2 : //Do we have a CRLF eol=strstr(soc->carpile,soc->EOL); if (eol==(char *)0) phase=999; //No End Of Line yet break; - case 2 : //duplicating carpile + case 3 : //duplicating carpile *lineptr=calloc(soc->carin+1,sizeof(char)); *eol='\000'; (void) strcpy(*lineptr,soc->carpile); got=strlen(*lineptr); break; - case 3 : //managing carpile + case 4 : //managing carpile soc->carin-=(got+strlen(soc->EOL)); if (soc->carin>0) { int delta; delta=got+strlen(soc->EOL); - (void) memmove(soc->carpile,soc->carpile+delta,soc->carin); + (void) memmove(soc->carpile,soc->carpile+delta,soc->carin+1); } - soc->carpile[soc->carin]='\000'; + //soc->carpile[soc->carin]='\000'; + (void) rou_alert(0,"%s carpile=<%s>",OPEP,soc->carpile); break; default : //SAFE guard proceed=false; diff --git a/lib/lvleml.c b/lib/lvleml.c index 243959b..383db7a 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -368,8 +368,10 @@ decoded=(char *)0; cur.tv_nsec/=10000; //100 millisec //(void) rou_asprintf(&seq,"<%05d-%s@%s>", // cur.tv_nsec,contact->session->sessid,contact->locname); -seq=strdup("<01234567890ABCDEFGHIJKLMNOPQRST@mailpostg.example.com>"); +//seq=strdup("<01234567890ABCDEFGHIJKLMNOPQRST@mailpostg.example.com>"); //seq=strdup("username = "); +//seq=strdup("realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8"); +seq=strdup("realm=\"example.com\",nonce=\"0123456789\",algorithm=md5-sess"); (void) rou_alert(0,"%s JMPDBG SEQ=<%s>",OPEP,seq); code=(char *)0; usr=(USRTYP *)0; -- 2.47.3