From f327310d7af092c3fb18dfecda4f5ee3fca7e82a Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 22 Apr 2009 03:12:30 +0000 Subject: [PATCH] Define and use MAX_TEXTDAT_LINE_LEN (2000 chars): This resolves JasHud's issue with question text.dat items over > 128 chars being truncated. --- src/sbbs3/readtext.c | 6 +++--- src/sbbs3/sbbs.h | 2 +- src/sbbs3/sbbsdefs.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/readtext.c b/src/sbbs3/readtext.c index a23674f876..7e813c8fce 100644 --- a/src/sbbs3/readtext.c +++ b/src/sbbs3/readtext.c @@ -7,7 +7,7 @@ /****************************************************************************/ char *readtext(long *line,FILE *stream,long dflt) { - char buf[2048],str[2048],tmp[256],*p,*p2; + char buf[MAX_TEXTDAT_ITEM_LEN+256],str[MAX_TEXTDAT_ITEM_LEN+1],tmp[256],*p,*p2; int i,j,k; if(!fgets(buf,256,stream)) { @@ -27,7 +27,7 @@ char *readtext(long *line,FILE *stream,long dflt) goto use_default; } if(*(p+1)=='\\') /* merge multiple lines */ - while(strlen(buf)<2000) { + while(strlen(buf)<MAX_TEXTDAT_ITEM_LEN) { if(!fgets(str,255,stream)) { /* Hide the EOF */ if(feof(stream)) @@ -47,7 +47,7 @@ char *readtext(long *line,FILE *stream,long dflt) } *(p)=0; k=strlen(buf); - for(i=1,j=0;i<k;j++) { + for(i=1,j=0;i<k && j<sizeof(str)-1;j++) { if(buf[i]=='\\') { /* escape */ i++; if(isdigit(buf[i])) { diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index be0fccb17e..dddba8f81c 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -538,7 +538,7 @@ public: char getkey(long mode); /* Waits for a key hit local or remote */ long getkeys(const char *str, ulong max); void ungetkey(char ch); /* Places 'ch' into the input buffer */ - char question[128]; + char question[MAX_TEXTDAT_ITEM_LEN+1]; bool yesno(const char *str); bool noyes(const char *str); void pause(void); diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h index 13296b4e3b..e02e2bcdac 100644 --- a/src/sbbs3/sbbsdefs.h +++ b/src/sbbs3/sbbsdefs.h @@ -99,6 +99,8 @@ typedef struct { #define MAX_FILES 10000 /* Maximum number of files per dir */ #define MAX_USERXFER 500 /* Maximum number of dest. users of usrxfer */ +#define MAX_TEXTDAT_ITEM_LEN 2000 + #define LEN_DIR 63 /* Maximum length of directory paths */ #define LEN_CMD 63 /* Maximum length of command lines */ -- GitLab