summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-12-26 14:35:16 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-12-26 14:35:16 +0800
commit5813df022c5ad24bc6f2d149884b035f6ba55721 (patch)
tree283d5ce092c0072fe19b72f6ffadc17c3c6b5622
parent0e1c81d4038faf0b4249899f56d1ead86ffd216f (diff)
downloadpttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar.gz
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar.bz2
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar.lz
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar.xz
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.tar.zst
pttbbs-5813df022c5ad24bc6f2d149884b035f6ba55721.zip
Ptt_prints prototype changed, length of input string should be given
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3459 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/proto.h2
-rw-r--r--mbbsd/kaede.c26
-rw-r--r--mbbsd/more.c4
-rw-r--r--mbbsd/pmore.c2
-rw-r--r--mbbsd/stuff.c2
5 files changed, 18 insertions, 18 deletions
diff --git a/include/proto.h b/include/proto.h
index dcab16bc..79d1a9b7 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -334,7 +334,7 @@ int Copy(const char *src, const char *dst);
int CopyN(const char *src, const char *dst, int n);
int AppendTail(const char *src, const char *dst, int off);
int Link(const char* src, const char* dst);
-char *Ptt_prints(char *str, int mode);
+char *Ptt_prints(char *str, size_t size, int mode);
char *my_ctime(const time4_t *t, char *ans, int len);
/* lovepaper */
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c
index 150d13f3..3f284adb 100644
--- a/mbbsd/kaede.c
+++ b/mbbsd/kaede.c
@@ -2,16 +2,16 @@
#include "bbs.h"
char *
-Ptt_prints(char *str, int mode)
+Ptt_prints(char *str, size_t size, int mode)
{
- char strbuf[256];
+ char *strbuf = alloca(size);
int r, w;
- for( r = w = 0 ; str[r] != 0 && w < (sizeof(strbuf) - 1) ; ++r )
+ for( r = w = 0 ; str[r] != 0 && w < (size - 1) ; ++r )
if( str[r] != ESC_CHR )
strbuf[w++] = str[r];
else{
if( str[++r] != '*' ){
- if(w+2>=sizeof(strbuf)-1) break;
+ if(w+2>=size-1) break;
strbuf[w++] = ESC_CHR;
strbuf[w++] = str[r];
}
@@ -19,15 +19,15 @@ Ptt_prints(char *str, int mode)
/* Note, w will increased by copied length after */
switch( str[++r] ){
case 's':
- strlcpy(strbuf+w, cuser.userid, sizeof(strbuf)-w);
+ strlcpy(strbuf+w, cuser.userid, size-w);
w += strlen(strbuf+w);
break;
case 't':
- strlcpy(strbuf+w, Cdate(&now), sizeof(strbuf)-w);
+ strlcpy(strbuf+w, Cdate(&now), size-w);
w += strlen(strbuf+w);
break;
case 'u':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%d", SHM->UTMPnumber);
break;
@@ -36,18 +36,18 @@ Ptt_prints(char *str, int mode)
*/
#ifdef LOW_SECURITY
case 'b':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%d/%d", cuser.month, cuser.day);
break;
case 'm':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%d", cuser.money);
break;
#else
#if 0
case 'm':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%s", money_level(cuser.money));
break;
#endif
@@ -55,15 +55,15 @@ Ptt_prints(char *str, int mode)
#endif
case 'l':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%d", cuser.numlogins);
break;
case 'p':
- w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ w += snprintf(&strbuf[w], size - w,
"%d", cuser.numposts);
break;
case 'n':
- strlcpy(strbuf+w, cuser.nickname, sizeof(strbuf)-w);
+ strlcpy(strbuf+w, cuser.nickname, size-w);
w += strlen(strbuf+w);
break;
/* It's saver not to send these undefined escape string.
diff --git a/mbbsd/more.c b/mbbsd/more.c
index 192f1aae..5fe300bf 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -268,9 +268,9 @@ more(char *fpath, int promptend)
strlcat(msg, buf1, sizeof(msg));
}
strlcat(msg, pos1, sizeof(msg));
- outs(Ptt_prints(msg, NO_RELOAD));
+ outs(Ptt_prints(msg, sizeof(msg), NO_RELOAD));
} else
- outs(Ptt_prints(buf, NO_RELOAD));
+ outs(Ptt_prints(buf, sizeof(buf), NO_RELOAD));
}
if (word) {
outs(ANSI_RESET);
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index 33364e28..26f73a38 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -1248,7 +1248,7 @@ mf_display()
override_msg = " 注意: 此頁有控制碼,"
"原內容並不一定有您真實個人資訊";
}
- Ptt_prints(buf, NO_RELOAD); // result in buf
+ Ptt_prints(buf, sizeof(buf), NO_RELOAD); // result in buf
}
i = strlen(buf);
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 088e3e56..3169721a 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -715,7 +715,7 @@ show_file(const char *filename, int y, int lines, int mode)
clrtoline(lines + y);
if ((fp = fopen(filename, "r"))) {
while (fgets(buf, sizeof(buf), fp) && lines--)
- outs(Ptt_prints(buf, mode));
+ outs(Ptt_prints(buf, sizeof(buf), mode));
fclose(fp);
} else
return 0;