From e0724377611ce98cd99154e60d441b44614e165b Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 15 Feb 2008 01:51:10 +0000 Subject: - testing to narrow down buffer overrun reason git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3921 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/io.c b/mbbsd/io.c index 3d6a36c5..66418259 100644 --- a/mbbsd/io.c +++ b/mbbsd/io.c @@ -6,13 +6,21 @@ #define OBUFSIZE 3072 #define IBUFSIZE 128 +/* realXbuf is Xbuf+3 because hz convert library requires buf[-2]. */ +#define CVTGAP (3) + #ifdef DEBUG #define register #endif -/* realXbuf is Xbuf+3 because hz convert library requires buf[-2]. */ -static unsigned char real_outbuf[OBUFSIZE+6] = " ", real_inbuf[IBUFSIZE+6] = " "; -static unsigned char *outbuf = real_outbuf + 3, *inbuf = real_inbuf + 3; +static unsigned char real_outbuf[OBUFSIZE + CVTGAP*2] = " ", + real_inbuf [IBUFSIZE + CVTGAP*2] = " "; + +// use defines instead - it is discovered that sometimes the input/output buffer was overflow, +// without knowing why. +// static unsigned char *outbuf = real_outbuf + 3, *inbuf = real_inbuf + 3; +#define inbuf (real_inbuf +CVTGAP) +#define outbuf (real_outbuf+CVTGAP) static int obufsize = 0, ibufsize = 0; static int icurrchar = 0; -- cgit v1.2.3