summaryrefslogtreecommitdiffstats
path: root/mbbsd/kaede.c
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 /mbbsd/kaede.c
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
Diffstat (limited to 'mbbsd/kaede.c')
-rw-r--r--mbbsd/kaede.c26
1 files changed, 13 insertions, 13 deletions
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.