From 018cc9df28836b066759137c19cd20afbee4b3ab Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 13 Mar 2002 12:32:33 +0000 Subject: [PATCH] Fixes for strings/files ending in a single Ctrl-A char. --- src/sbbs3/js_msgbase.c | 2 +- src/sbbs3/misc.c | 4 ++-- src/sbbs3/putmsg.cpp | 2 +- src/sbbs3/qwknodes.c | 2 +- src/sbbs3/str.cpp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sbbs3/js_msgbase.c b/src/sbbs3/js_msgbase.c index 0bc18c08d2..557e4610fa 100644 --- a/src/sbbs3/js_msgbase.c +++ b/src/sbbs3/js_msgbase.c @@ -504,7 +504,7 @@ static char* get_msg_text(smb_t* smb, smbmsg_t* msg, BOOL strip_ctrl_a, ulong mo if((newbuf=malloc(strlen(buf)+1))!=NULL) { int i,j; for(i=j=0;buf[i];i++) { - if(buf[i]==CTRL_A) + if(buf[i]==CTRL_A && buf[i+1]!=0) i++; else newbuf[j++]=buf[i]; } diff --git a/src/sbbs3/misc.c b/src/sbbs3/misc.c index 20602772ec..dd8f63094c 100644 --- a/src/sbbs3/misc.c +++ b/src/sbbs3/misc.c @@ -140,7 +140,7 @@ char* DLLCALL strip_ctrl(char *str) int i,j; for(i=j=0;str[i] && j<sizeof(tmp)-1;i++) - if(str[i]==CTRL_A) + if(str[i]==CTRL_A && str[i+1]!=0) i++; else if((uchar)str[i]>=SP) tmp[j++]=str[i]; @@ -168,7 +168,7 @@ char* DLLCALL prep_file_desc(char *str) int i,j; for(i=j=0;str[i];i++) - if(str[i]==CTRL_A) + if(str[i]==CTRL_A && str[i+1]!=0) i++; else if(j && str[i]<=SP && tmp[j-1]==SP) continue; diff --git a/src/sbbs3/putmsg.cpp b/src/sbbs3/putmsg.cpp index fa2f93e3ef..59847be399 100644 --- a/src/sbbs3/putmsg.cpp +++ b/src/sbbs3/putmsg.cpp @@ -58,7 +58,7 @@ char sbbs_t::putmsg(char HUGE16 *str, long mode) if(!(mode&P_SAVEATR)) attr(LIGHTGRAY); while(str[l] && (mode&P_NOABORT || !msgabort()) && online) { - if(str[l]==CTRL_A) { + if(str[l]==CTRL_A && str[l+1]!=0) { if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */ l+=2; i=0; diff --git a/src/sbbs3/qwknodes.c b/src/sbbs3/qwknodes.c index f959805263..dfd26b9aa6 100644 --- a/src/sbbs3/qwknodes.c +++ b/src/sbbs3/qwknodes.c @@ -192,7 +192,7 @@ void stripctrla(uchar *str) int i,j; for(i=j=0;str[i];i++) { - if(str[i]==CTRL_A) + if(str[i]==CTRL_A && str[i+1]!=0) i++; else out[j++]=str[i]; } diff --git a/src/sbbs3/str.cpp b/src/sbbs3/str.cpp index 5fb4df9512..99f3b03d0a 100644 --- a/src/sbbs3/str.cpp +++ b/src/sbbs3/str.cpp @@ -49,8 +49,8 @@ char* DLLCALL remove_ctrl_a(char *instr, char *outstr) char str[1024],*p; uint i,j; - for(i=j=0;instr[i];i++) { - if(instr[i]==CTRL_A) + for(i=j=0;instr[i] && j<sizeof(str)-1;i++) { + if(instr[i]==CTRL_A && instr[i+1]!=0) i++; else str[j++]=instr[i]; } -- GitLab