crash in bigsay (#20)

* crash in bigsay
This commit is contained in:
joonicks 2018-03-22 16:43:20 +01:00 committed by GitHub
parent 7aba5eddf4
commit 67695c7ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,6 @@
3.0.99p4 -- WORK IN PROGRESS (~March, 2018) 3.0.99p4 -- WORK IN PROGRESS (~March, 2018)
* Fixed: Crash bug in BIGSAY
* Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG * Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG
* Added: New command: CRASH, for debugging/development... * Added: New command: CRASH, for debugging/development...
* Changed: configure now defaults to optimizing for code size. * Changed: configure now defaults to optimizing for code size.

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 2000-2004 proton Copyright (c) 2000-2018 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -199,7 +199,7 @@ void do_bigsay(COMMAND_ARGS)
BigC *bigc; BigC *bigc;
Strp *sp; Strp *sp;
char output[MSGLEN]; char output[MSGLEN];
char *pt,*tail,*temp; char *pt,*tail,*temp,*temp2;
int i,x,sz; int i,x,sz;
#ifdef DEBUG #ifdef DEBUG
@ -214,6 +214,7 @@ void do_bigsay(COMMAND_ARGS)
return; return;
} }
#define OEND (output + MSGLEN - 1)
for(i=0;i<charheight;i++) for(i=0;i<charheight;i++)
{ {
sz = 0; sz = 0;
@ -225,7 +226,7 @@ void do_bigsay(COMMAND_ARGS)
if (*pt == ' ') if (*pt == ' ')
{ {
x = spacewidth; x = spacewidth;
while(x--) while(x-- && tail < OEND)
*(tail++) = ' '; *(tail++) = ' ';
*tail = 0; *tail = 0;
continue; continue;
@ -237,17 +238,20 @@ void do_bigsay(COMMAND_ARGS)
sp = bigc->data; sp = bigc->data;
for(x=0;x<i;x++) for(x=0;x<i;x++)
if (sp) sp = sp->next; if (sp) sp = sp->next;
temp = Strcat(tail,sp->p); temp = sp->p;
while(temp < (tail + bigc->width)) temp2 = tail;
*(temp++) = ' '; while(*temp && tail < OEND)
*(tail++) = *(temp++);
//temp = Strcat(tail,sp->p);
while(tail < (temp2 + bigc->width) && tail < OEND)
*(tail++) = ' ';
if (pt[1]) if (pt[1])
{ {
x = kerning; x = kerning;
while(x--) while(x-- && tail < OEND)
*(temp++) = ' '; *(tail++) = ' ';
} }
*temp = 0; *tail = 0;
tail = temp;
break; break;
} }
} }