From 8b45fd166b943e17dabb3f5cdf972baeb58e0346 Mon Sep 17 00:00:00 2001 From: in2 Date: Mon, 22 Jul 2002 19:02:01 +0000 Subject: sprintf() -> snprintf() git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@435 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/edit.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'mbbsd/edit.c') diff --git a/mbbsd/edit.c b/mbbsd/edit.c index 212f893b..ad210b12 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1,4 +1,4 @@ -/* $Id: edit.c,v 1.14 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: edit.c,v 1.15 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" typedef struct textline_t { struct textline_t *prev; @@ -784,9 +784,11 @@ write_header(FILE * fp) ifuseanony = 1; } else { if (!strcmp("r", real_name) || (!defanony && !real_name[0])) - sprintf(postlog.author, "%s", cuser.userid); + snprintf(postlog.author, sizeof(postlog.author), + "%s", cuser.userid); else { - sprintf(postlog.author, "%s.", real_name); + snprintf(postlog.author, sizeof(postlog.author), + "%s.", real_name); ifuseanony = 1; } } @@ -1644,7 +1646,7 @@ vedit(char *fpath, int saveheader, int *islocal) } /* 連續240個interval一樣 , 分明是在斂財 */ if (count >= 240) { - sprintf(buf, "\033[1;33;46m%s\033[37m在\033[37;45m%s" + snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m在\033[37;45m%s" "\033[37m板違法賺錢 , %s\033[m", cuser.userid, currboard, ctime(&now)); log_file("etc/illegal_money", buf); @@ -1782,25 +1784,26 @@ vedit(char *fpath, int saveheader, int *islocal) strlcpy(color, "\033[", sizeof(color)); if (isdigit(*apos)) { - sprintf(color, "%s%c", color, *(apos++)); + snprintf(color, sizeof(color), + "%s%c", color, *(apos++)); if (*apos) - sprintf(color, "%s;", color); + snprintf(color, sizeof(color), "%s;", color); } if (*apos) { if ((tmp = strchr(t, toupper(*(apos++))))) fg = tmp - t + 30; else fg = 37; - sprintf(color, "%s%d", color, fg); + snprintf(color, sizeof(color), "%s%d", color, fg); } if (*apos) { if ((tmp = strchr(t, toupper(*(apos++))))) bg = tmp - t + 40; else bg = 40; - sprintf(color, "%s;%d", color, bg); + snprintf(color, sizeof(color), "%s;%d", color, bg); } - sprintf(color, "%sm", color); + snprintf(color, sizeof(color), "%sm", color); insert_string(color); } else insert_string(reset_color); -- cgit v1.2.3