Skip to content
Snippets Groups Projects
Commit 018cc9df authored by rswindell's avatar rswindell
Browse files

Fixes for strings/files ending in a single Ctrl-A char.

parent 8315ffd9
No related branches found
No related tags found
No related merge requests found
......@@ -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];
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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]; }
......
......@@ -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];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment