summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/mbbsd/read.c17
-rw-r--r--pttbbs/mbbsd/var.c2
2 files changed, 16 insertions, 3 deletions
diff --git a/pttbbs/mbbsd/read.c b/pttbbs/mbbsd/read.c
index 4616cd62..ba9aa67e 100644
--- a/pttbbs/mbbsd/read.c
+++ b/pttbbs/mbbsd/read.c
@@ -423,7 +423,6 @@ select_read(const keeploc_t * locmem, int sr_mode)
char keyword[TTLEN + 1] = "";
int n_recommend = 0, n_money = 0;
-
if(locmem->crs_ln == 0)
return locmem->crs_ln;
@@ -501,8 +500,22 @@ select_read(const keeploc_t * locmem, int sr_mode)
snprintf(genbuf, sizeof(genbuf), "%s%X.%X.%X",
first_select ? "SR.":p,
sr_mode, (int)strlen(keyword), DBCS_StringHash(keyword));
- if( strlen(genbuf) > PATHLEN - 50 )
+
+ // pre-calculate board prefix
+ if (currstat == RMAIL)
+ sethomefile(newdirect, cuser.userid, "x");
+ else
+ setbfile(newdirect, currboard, "x");
+
+ // XXX currently currdirect is 64 bytes while newdirect is 256 bytes.
+ // however if we enlarge currdirect, there may be lots of SR generated.
+ // as a result, let's make restriction here.
+ assert( sizeof(newdirect) >= sizeof(currdirect) );
+ if( strlen(genbuf) + strlen(newdirect) >= sizeof(currdirect) )
+ {
+ vmsg("抱歉,已達搜尋條件上限。");
return READ_REDRAW; // avoid overflow
+ }
if (currstat == RMAIL)
sethomefile(newdirect, cuser.userid, genbuf);
diff --git a/pttbbs/mbbsd/var.c b/pttbbs/mbbsd/var.c
index c46cde6a..b9d8ad74 100644
--- a/pttbbs/mbbsd/var.c
+++ b/pttbbs/mbbsd/var.c
@@ -361,7 +361,7 @@ userinfo_t *currutmp;
int TagNum = 0; /* tag's number */
int TagBoard = -1; /* TagBoard = 0 : user's mailbox */
/* TagBoard > 0 : bid where last taged */
-char currdirect[64];
+char currdirect[64]; /* XXX TODO change this to PATHLEN? */
/* bbs.c */
char real_name[IDLEN + 1];