diff options
Diffstat (limited to 'mbbsd')
42 files changed, 709 insertions, 562 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index a9fe35ca..a060a123 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -1,4 +1,4 @@ -/* $Id: admin.c,v 1.28 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: admin.c,v 1.29 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* �ϥΪ̺z */ @@ -41,7 +41,7 @@ search_key_user(char *passwdfile, int mode) while ((fread(&user, sizeof(user), 1, fp1)) > 0 && coun < MAX_USERS) { if (!(++coun & 15)) { move(1, 0); - sprintf(buf, "�� [%d] �����\n", coun); + snprintf(buf, sizeof(buf), "�� [%d] �����\n", coun); outs(buf); refresh(); } @@ -52,7 +52,7 @@ search_key_user(char *passwdfile, int mode) strstr(user.address, key) || strstr(user.justify, key) || strstr(user.mychicken.name, key)))) { move(1, 0); - sprintf(buf, "�� [%d] �����\n", coun); + snprintf(buf, sizeof(buf), "�� [%d] �����\n", coun); outs(buf); refresh(); @@ -218,7 +218,7 @@ m_mod_board(char *bname) /* Ptt �o���_��|�ɨ�U�� */ move(9, 0); - sprintf(genbuf, "(E)�]�w (V)�H�k/�Ѱ� %s (D)�R�� [Q]�����H", + snprintf(genbuf, sizeof(genbuf), "(E)�]�w (V)�H�k/�Ѱ� %s (D)�R�� [Q]�����H", HAS_PERM(PERM_SYSOP) ? " (B)BVote (S)�Ϧ^�峹 (G)��L�ѥd" : ""); getdata(10, 0, genbuf, ans, sizeof(ans), LCECHO); @@ -234,8 +234,9 @@ m_mod_board(char *bname) break; case 's': if (HAS_PERM(PERM_SYSOP)) { - sprintf(genbuf, BBSHOME "/bin/buildir boards/%c/%s &", - bh.brdname[0], bh.brdname); + snprintf(genbuf, sizeof(genbuf), + BBSHOME "/bin/buildir boards/%c/%s &", + bh.brdname[0], bh.brdname); system(genbuf); } break; @@ -244,7 +245,7 @@ m_mod_board(char *bname) char bvotebuf[10]; memcpy(&newbh, &bh, sizeof(bh)); - sprintf(bvotebuf, "%d", newbh.bvote); + snprintf(bvotebuf, sizeof(bvotebuf), "%d", newbh.bvote); move(20, 0); prints("�ݪO %s ��Ӫ� BVote�G%d", bh.brdname, bh.bvote); getdata_str(21, 0, "�s�� Bvote�G", genbuf, 5, LCECHO, bvotebuf); @@ -275,15 +276,16 @@ m_mod_board(char *bname) if (genbuf[0] != 'y' || !bname[0]) outs(MSG_DEL_CANCEL); else { - strlcpy(bname, bh.brdname, SIZEOF(bname)); - sprintf(genbuf, + strlcpy(bname, bh.brdname, sizeof(bh.brdname)); + snprintf(genbuf, sizeof(genbuf), "/bin/tar zcvf tmp/board_%s.tgz boards/%c/%s man/boards/%c/%s >/dev/null 2>&1;" "/bin/rm -fr boards/%c/%s man/boards/%c/%s", bname, bname[0], bname, bname[0], bname, bname[0], bname, bname[0], bname); system(genbuf); memset(&bh, 0, sizeof(bh)); - sprintf(bh.title, "%s �ݪO %s �R��", bname, cuser.userid); + snprintf(bh.title, sizeof(bh.title), + "%s �ݪO %s �R��", bname, cuser.userid); post_msg("Security", bh.title, "�Ъ`�N�R�����X�k��", "[�t�Φw����]"); substitute_record(fn_board, &bh, sizeof(bh), bid); reset_board(bid); @@ -749,7 +751,7 @@ scan_register_form(char *regfile, int automode, int neednum) int nSelf = 0, nAuto = 0; uid = cuser.userid; - sprintf(fname, "%s.tmp", regfile); + snprintf(fname, sizeof(fname), "%s.tmp", regfile); move(2, 0); if (dashf(fname)) { if (neednum == 0) { /* �ۤv�i Admin �Ӽf�� */ @@ -777,7 +779,7 @@ scan_register_form(char *regfile, int automode, int neednum) *ptr = '\0'; for (n = 0; field[n]; n++) { if (strcmp(genbuf, field[n]) == 0) { - strlcpy(fdata[n], ptr + 2, SIZEOF(fdata[n])); + strlcpy(fdata[n], ptr + 2, sizeof(fdata[n])); if ((ptr = (char *)strchr(fdata[n], '\n'))) *ptr = '\0'; } @@ -877,7 +879,8 @@ scan_register_form(char *regfile, int automode, int neednum) i = buf[0] - '0'; strlcpy(buf, reason[i], sizeof(buf)); - sprintf(genbuf, "[�h�^��]] ��%s", buf); + snprintf(genbuf, sizeof(genbuf), + "[�h�^��]] ��%s", buf); sethomepath(buf1, muser.userid); stampfile(buf1, &mhdr); @@ -918,7 +921,8 @@ scan_register_form(char *regfile, int automode, int neednum) strlcpy(muser.realname, fdata[2], sizeof(muser.realname)); strlcpy(muser.address, fdata[4], sizeof(muser.address)); strlcpy(muser.email, fdata[6], sizeof(muser.email)); - sprintf(genbuf, "%s:%s:%s", fdata[5], fdata[3], uid); + snprintf(genbuf, sizeof(genbuf), + "%s:%s:%s", fdata[5], fdata[3], uid); strncpy(muser.justify, genbuf, REGLEN); sethomefile(buf, muser.userid, "justify"); log_file(buf, genbuf); @@ -1029,7 +1033,7 @@ give_id_money(char *user_id, int money, FILE * log_fp, char *mail_title, time_t pressanykey(); } else { fprintf(log_fp, "%ld %s %d", t, user_id, money); - sprintf(tt, "%s : %d ptt ��", mail_title, money); + snprintf(tt, sizeof(tt), "%s : %d ptt ��", mail_title, money); mail_id(user_id, tt, "~bbs/etc/givemoney.why", "[PTT �Ȧ�]"); } } diff --git a/mbbsd/announce.c b/mbbsd/announce.c index 5df8a9fa..8413897b 100644 --- a/mbbsd/announce.c +++ b/mbbsd/announce.c @@ -1,4 +1,4 @@ -/* $Id: announce.c,v 1.15 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: announce.c,v 1.16 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static void @@ -403,7 +403,7 @@ a_showmenu(menu_t * pm) /* * Ptt ��ɶ��אּ���ɮɶ� dtime = atoi(&item->filename[2]); */ - sprintf(buf, "%s/%s", pm->path, item->filename); + snprintf(buf, sizeof(buf), "%s/%s", pm->path, item->filename); dtime = dasht(buf); a_timestamp(buf, &dtime); prints("\n%6d%c %-47.46s%-13s[%s]", pm->page + n + 1, @@ -629,7 +629,7 @@ gem(char *maintitle, item_t * path, int update) } else stampdir(newpath, &item); strlcpy(item.owner, cuser.userid, sizeof(item.owner)); - sprintf(item.title, "%s%.72s", + snprintf(item.title, sizeof(item.title), "%s%.72s", (currutmp->pager > 1) ? "" : (mode == (char)0xbc) ? "�� " : "�� ", title + 3); @@ -806,19 +806,19 @@ a_newitem(menu_t * pm, int mode) for (d = 0; d <= 3; d++) { switch (d) { case 0: - sprintf(lpath, BBSHOME "/man/boards/%c/%s/%s", + snprintf(lpath, sizeof(lpath), BBSHOME "/man/boards/%c/%s/%s", currboard[0], currboard, buf); break; case 1: - sprintf(lpath, "%s%s/%c/%s", + snprintf(lpath, sizeof(lpath), "%s%s/%c/%s", BBSHOME, "/man/boards/", buf[0], buf); break; case 2: - sprintf(lpath, "%s%s%s", + snprintf(lpath, sizeof(lpath), "%s%s%s", BBSHOME, "/", buf); break; case 3: - sprintf(lpath, "%s%s%s", + snprintf(lpath, sizeof(lpath), "%s%s%s", BBSHOME, "/etc/", buf); break; } @@ -894,7 +894,8 @@ a_pasteitem(menu_t * pm, int mode) } } if (mode) { - sprintf(buf, "�T�w�n����[%s]��(Y/N)�H[N] ", copytitle); + snprintf(buf, sizeof(buf), + "�T�w�n����[%s]��(Y/N)�H[N] ", copytitle); getdata(b_lines - 1, 1, buf, ans, sizeof(ans), LCECHO); } else ans[0] = 'y'; @@ -916,18 +917,20 @@ a_pasteitem(menu_t * pm, int mode) if (HAS_PERM(PERM_BBSADM)) Link(copyfile, newpath); else { - sprintf(buf, "/bin/cp %s %s", copyfile, newpath); + snprintf(buf, sizeof(buf), + "/bin/cp %s %s", copyfile, newpath); system(buf); } } else if (dashf(copyfile)) { stampfile(newpath, &item); memcpy(copytitle, "��", 2); - sprintf(buf, "/bin/cp %s %s", copyfile, newpath); + snprintf(buf, sizeof(buf), "/bin/cp %s %s", copyfile, newpath); } else if (dashd(copyfile)) { stampdir(newpath, &item); memcpy(copytitle, "��", 2); - sprintf(buf, "/bin/cp -r %s/* %s/.D* %s", copyfile, copyfile, - newpath); + snprintf(buf, sizeof(buf), + "/bin/cp -r %s/* %s/.D* %s", copyfile, copyfile, + newpath); } else { outs("�L�k�����I"); igetch(); @@ -958,12 +961,12 @@ a_appenditem(menu_t * pm, int isask) move(b_lines - 1, 1); if (copyfile[0]) { if (dashf(copyfile)) { - sprintf(fname, "%s/%s", pm->path, + snprintf(fname, sizeof(fname), "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); if (dashf(fname)) { if (isask) { - sprintf(buf, "�T�w�n�N[%s]���[��(Y/N)�H[N] ", - copytitle); + snprintf(buf, sizeof(buf), + "�T�w�n�N[%s]���[��(Y/N)�H[N] ", copytitle); getdata(b_lines - 2, 1, buf, ans, sizeof(ans), LCECHO); } if (ans[0] == 'y') { @@ -1046,7 +1049,7 @@ a_moveitem(menu_t * pm) char buf[PATHLEN]; int fail; - sprintf(buf, "�п�J�� %d �ﶵ���s���ǡG", pm->now + 1); + snprintf(buf, sizeof(buf), "�п�J�� %d �ﶵ���s���ǡG", pm->now + 1); if (!getdata(b_lines - 1, 1, buf, newnum, sizeof(newnum), DOECHO)) return; num = (newnum[0] == '$') ? 9999 : atoi(newnum) - 1; @@ -1084,7 +1087,7 @@ a_delrange(menu_t * pm) { char fname[256]; - sprintf(fname, "%s/.DIR", pm->path); + snprintf(fname, sizeof(fname), "%s/.DIR", pm->path); del_range(0, NULL, fname); pm->num = get_num_records(fname, FHSZ); } @@ -1096,7 +1099,8 @@ a_delete(menu_t * pm) char ans[4]; fileheader_t backup; - sprintf(fpath, "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); + snprintf(fpath, sizeof(fpath), + "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); setadir(buf, pm->path); if (pm->header[pm->now - pm->page].filename[0] == 'H' && @@ -1130,7 +1134,8 @@ a_delete(menu_t * pm) pm->header[pm->now - pm->page].title + 2, sizeof(backup.title)); - sprintf(cmd, "mv -f %s %s", fpath, buf); + snprintf(cmd, sizeof(cmd), + "mv -f %s %s", fpath, buf); system(cmd); setbdir(buf, "deleted"); append_record(buf, &backup, sizeof(backup)); @@ -1145,7 +1150,8 @@ a_delete(menu_t * pm) setapath(buf, "deleted"); stampdir(buf, &backup); - sprintf(cmd, "rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf); + snprintf(cmd, sizeof(cmd), + "rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf); system(cmd); strlcpy(backup.owner, cuser.userid, sizeof(backup.owner)); @@ -1202,7 +1208,7 @@ a_editsign(menu_t * pm) fileheader_t item; memcpy(&item, &pm->header[pm->now - pm->page], FHSZ); - sprintf(buf, "%c%c", item.title[0], item.title[1]); + snprintf(buf, sizeof(buf), "%c%c", item.title[0], item.title[1]); if (getdata_buf(b_lines - 1, 1, "�Ÿ�", buf, 5, DOECHO)) { item.title[0] = buf[0] ? buf[0] : ' '; item.title[1] = buf[1] ? buf[1] : ' '; @@ -1221,7 +1227,8 @@ a_showname(menu_t * pm) int sym; move(b_lines - 1, 1); - sprintf(buf, "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); + snprintf(buf, sizeof(buf), + "%s/%s", pm->path, pm->header[pm->now - pm->page].filename); if (dashl(buf)) { prints("�� symbolic link �W�٬� %s\n", pm->header[pm->now - pm->page].filename); @@ -1392,7 +1399,8 @@ a_menu(char *maintitle, char *path, int lastlevel) case 'e': case 'E': - sprintf(fname, "%s/%s", path, me.header[me.now - me.page].filename); + snprintf(fname, sizeof(fname), + "%s/%s", path, me.header[me.now - me.page].filename); if (dashf(fname) && me.level >= MANAGER) { *quote_file = 0; if (vedit(fname, NA, NULL) != -1) { @@ -1421,8 +1429,8 @@ a_menu(char *maintitle, char *path, int lastlevel) if (me.now < me.num) { if (!isvisible_man(&me)) break; - sprintf(fname, "%s/%s", path, - me.header[me.now - me.page].filename); + snprintf(fname, sizeof(fname), "%s/%s", path, + me.header[me.now - me.page].filename); a_copyitem(fname, me.header[me.now - me.page].title, 0, 1); me.page = 9999; break; @@ -1435,7 +1443,7 @@ a_menu(char *maintitle, char *path, int lastlevel) fileheader_t *fhdr = &me.header[me.now - me.page]; if (!isvisible_man(&me)) break; - sprintf(fname, "%s/%s", path, fhdr->filename); + snprintf(fname, sizeof(fname), "%s/%s", path, fhdr->filename); if (*fhdr->filename == 'H' && fhdr->filename[1] == '.') { item_t item; strlcpy(item.X.G.server, fhdr->filename + 2, @@ -1483,8 +1491,8 @@ a_menu(char *maintitle, char *path, int lastlevel) break; if (!isvisible_man(&me)) break; - sprintf(fname, "%s/%s", path, - me.header[me.now - me.page].filename); + snprintf(fname, sizeof(fname), "%s/%s", path, + me.header[me.now - me.page].filename); if (!dashf(fname)) break; } @@ -1502,7 +1510,8 @@ a_menu(char *maintitle, char *path, int lastlevel) case 'F': case 'U': - sprintf(fname, "%s/%s", path, me.header[me.now - me.page].filename); + snprintf(fname, sizeof(fname), + "%s/%s", path, me.header[me.now - me.page].filename); if (me.now < me.num && HAS_PERM(PERM_BASIC) && dashf(fname)) { a_forward(path, &me.header[me.now - me.page], ch /* == 'U' */ ); /* By CharlieL */ diff --git a/mbbsd/args.c b/mbbsd/args.c index e517b512..1d128673 100644 --- a/mbbsd/args.c +++ b/mbbsd/args.c @@ -1,4 +1,4 @@ -/* $Id: args.c,v 1.6 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: args.c,v 1.7 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #ifdef HAVE_SETPROCTITLE @@ -49,7 +49,7 @@ do_setproctitle(const char *cmdline) if (i > LastArgv - Argv[0] - 2) { i = LastArgv - Argv[0] - 2; } - strlcpy(Argv[0], buf, SIZEOF(Argv[0]); + strlcpy(Argv[0], buf, sizeof(buf)); p = &Argv[0][i]; while (p < LastArgv) *p++ = '\0'; @@ -62,7 +62,7 @@ setproctitle(const char *format,...) char buf[256]; va_list args; va_start(args, format); - vsprintf(buf, format, args); + vsnprintf(buf, sizeof(buf), format, args); do_setproctitle(buf); va_end(args); } diff --git a/mbbsd/bbcall.c b/mbbsd/bbcall.c index c3527e01..676816f7 100644 --- a/mbbsd/bbcall.c +++ b/mbbsd/bbcall.c @@ -1,4 +1,4 @@ -/* $Id: bbcall.c,v 1.7 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: bbcall.c,v 1.8 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define SERVER_0941 "www.chips.com.tw" @@ -144,7 +144,8 @@ static void halpha0943(char* CoId) { char Msg[64], atrn[512], sendform[1024]; int Year = 99, Month = 1, Day = 15, Hour = 13, Minute = 8; - sprintf(tmpbuf, "\033[1;37m�п�J�z�n�ǩI�����X\033[m : %s-", CoId); + snprintf(tmpbuf, sizeof(tmpbuf), + "\033[1;37m�п�J�z�n�ǩI�����X\033[m : %s-", CoId); if(!getdata(7,0, tmpbuf, ID, sizeof(ID), LCECHO) || !getdata(8,0, "\033[1;37m�п�J�ǩI�T��\033[m�G", tmpbuf, 63, LCECHO)) { hpressanykey("���ǩI"); @@ -157,10 +158,11 @@ static void halpha0943(char* CoId) { if(ans[0] != '1') Gettime(0, &Year, &Month, &Day, &Hour, &Minute); - sprintf(atrn, "CoId=%s&ID=%s&Year=19%02d&Month=%02d&Day=%02d" - "&Hour=%02d&Minute=%02d&Msg=%s", - CoId, ID,Year,Month,Day,Hour,Minute,Msg); - sprintf(sendform, "POST %s HTTP/1.0\nReferer: " + snprintf(atrn, sizeof(atrn), + "CoId=%s&ID=%s&Year=19%02d&Month=%02d&Day=%02d" + "&Hour=%02d&Minute=%02d&Msg=%s", + CoId, ID,Year,Month,Day,Hour,Minute,Msg); + snprintf(sendform, sizeof(sendform), "POST %s HTTP/1.0\nReferer: " "%s\n%sContent-length:%d\n\n%s", CGI_0943, REFER_0943, PARA, strlen(atrn), atrn); Connect(sendform, SERVER_0943); @@ -187,13 +189,15 @@ static void hcall0941() { Gettime(0, &year, &month, &day, &hour, &min); } else strlcpy(TIME, "NOW", sizeof(TIME)); - sprintf(trn,"PAGER_NO=%s&TRAN_MSG=%s&MSG_TYPE=NUMERIC&%s=1" - "&year=19%02d&month=%02d&day=%02d&hour=%02d&min=%02d", - PAGER_NO, TRAN_MSG, TIME,year,month,day,hour,min); + snprintf(trn, sizeof(trn), + "PAGER_NO=%s&TRAN_MSG=%s&MSG_TYPE=NUMERIC&%s=1" + "&year=19%02d&month=%02d&day=%02d&hour=%02d&min=%02d", + PAGER_NO, TRAN_MSG, TIME,year,month,day,hour,min); - sprintf(sendform, "POST %s HTTP/1.0\nReferer: %s\n%s" - "Content-length:%d\n\n%s", - CGI_0941, REFER_0941, PARA, strlen(trn), trn); + snprintf(sendform, sizeof(sendform), + "POST %s HTTP/1.0\nReferer: %s\n%s" + "Content-length:%d\n\n%s", + CGI_0941, REFER_0941, PARA, strlen(trn), trn); Connect(sendform, SERVER_0941); return ; @@ -220,11 +224,13 @@ static void hcall0948() { ya = 1; } - sprintf(trn, "MfcISAPICommand=SinglePage&svc_no=%s&reminder=%d" - "&year=%02d&month=%02d&day=%02d&hour=%02d&min=%02d&message=%s", + snprintf(trn, sizeof(trn), + "MfcISAPICommand=SinglePage&svc_no=%s&reminder=%d" + "&year=%02d&month=%02d&day=%02d&hour=%02d&min=%02d&message=%s", svc_no, ya, year, month, day, hour, min, message); - sprintf(sendform, "GET %s?%s Http/1.0\n\n", CGI_0948, trn); + snprintf(sendform, sizeof(sendform), + "GET %s?%s Http/1.0\n\n", CGI_0948, trn); Connect(sendform, SERVER_0948); return; diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index a706ff0c..84749b1c 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1,4 +1,4 @@ -/* $Id: bbs.c,v 1.65 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: bbs.c,v 1.66 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static void @@ -7,13 +7,15 @@ mail_by_link(char *owner, char *title, char *path) char genbuf[200]; fileheader_t mymail; - sprintf(genbuf, BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid); + snprintf(genbuf, sizeof(genbuf), + BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid); stampfile(genbuf, &mymail); strlcpy(mymail.owner, owner, sizeof(mymail.owner)); - sprintf(mymail.title, title); + snprintf(mymail.title, sizeof(mymail.title), title); unlink(genbuf); Link(path, genbuf); - sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid); + snprintf(genbuf, sizeof(genbuf), + BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid); append_record(genbuf, &mymail, sizeof(mymail)); } @@ -24,7 +26,7 @@ anticrosspost() { char buf[200]; - sprintf(buf, + snprintf(buf, sizeof(buf), "\033[1;33;46m%s \033[37;45mcross post �峹 \033[37m %s\033[m", cuser.userid, ctime(&now)); log_file("etc/illegal_money", buf); @@ -55,9 +57,9 @@ save_violatelaw() } reload_money(); if (cuser.money < (int)cuser.vl_count * 1000) { - sprintf(buf, "\033[1;31m�o�O�A�� %d ���H�ϥ����k�W" - "����ú�X %d $Ptt ,�A�u�� %d ��, ��������!!\033[m", - (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money); + snprintf(buf, sizeof(buf), "\033[1;31m�o�O�A�� %d ���H�ϥ����k�W" + "����ú�X %d $Ptt ,�A�u�� %d ��, ��������!!\033[m", + (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money); mprints(22, 0, buf); pressanykey(); return 0; @@ -74,8 +76,8 @@ save_violatelaw() pressanykey(); return 0; } - sprintf(buf, "�o�O�A�� %d ���H�k ����ú�X %d $Ptt", - cuser.vl_count, cuser.vl_count * 1000); + snprintf(buf, sizeof(buf), "�o�O�A�� %d ���H�k ����ú�X %d $Ptt", + cuser.vl_count, cuser.vl_count * 1000); mprints(11, 0, buf); if (!getdata(10, 0, "�n�I��[y/n]:", ok, sizeof(ok), LCECHO) || @@ -108,7 +110,7 @@ set_board() brd_title = bp->BM; if (brd_title[0] <= ' ') brd_title = "�x�D��"; - sprintf(currBM, "�O�D�G%s", brd_title); + snprintf(currBM, sizeof(currBM), "�O�D�G%s", brd_title); brd_title = ((bp->bvote != 2 && bp->bvote) ? "���ݪO�i��벼��" : bp->title + 7); currmode = (currmode & (MODE_DIRTY | MODE_MENU)) | MODE_STARTED; @@ -359,11 +361,11 @@ do_reply_title(int row, char *title) char genbuf2[4]; if (strncasecmp(title, str_reply, 4)) - sprintf(save_title, "Re: %s", title); + snprintf(save_title, sizeof(save_title), "Re: %s", title); else strlcpy(save_title, title, sizeof(save_title)); save_title[TTLEN - 1] = '\0'; - sprintf(genbuf, "�ĥέ���D�m%.60s�n��?[Y] ", save_title); + snprintf(genbuf, sizeof(genbuf), "�ĥέ���D�m%.60s�n��?[Y] ", save_title); getdata(row, 0, genbuf, genbuf2, 4, LCECHO); if (genbuf2[0] == 'n' || genbuf2[0] == 'N') getdata(++row, 0, "���D�G", save_title, TTLEN, DOECHO); @@ -446,7 +448,8 @@ do_general() save_title, 3, LCECHO); local_article = save_title[0] - '1'; if (local_article >= 0 && local_article <= 6) - sprintf(save_title, "[%s] ", ctype[local_article]); + snprintf(save_title, sizeof(save_title), + "[%s] ", ctype[local_article]); else save_title[0] = '\0'; getdata_buf(22, 0, "���D�G", save_title, TTLEN, DOECHO); @@ -799,11 +802,11 @@ cross_post(int ent, fileheader_t * fhdr, char *direct) } } if (ent) - sprintf(xtitle, "[���]%.66s", fhdr->title); + snprintf(xtitle, sizeof(xtitle), "[���]%.66s", fhdr->title); else strlcpy(xtitle, fhdr->title, sizeof(xtitle)); - sprintf(genbuf, "�ĥέ���D�m%.60s�n��?[Y] ", xtitle); + snprintf(genbuf, sizeof(genbuf), "�ĥέ���D�m%.60s�n��?[Y] ", xtitle); getdata(2, 0, genbuf, genbuf2, 4, LCECHO); if (genbuf2[0] == 'n' || genbuf2[0] == 'N') { if (getdata_str(2, 0, "���D�G", genbuf, TTLEN, DOECHO, xtitle)) @@ -980,7 +983,7 @@ b_man() if ((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)) { char genbuf[128]; int fd; - sprintf(genbuf, "%s/.rebuild", buf); + snprintf(genbuf, sizeof(genbuf), "%s/.rebuild", buf); if ((fd = open(genbuf, O_CREAT, 0640)) > 0) close(fd); } @@ -1082,17 +1085,18 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct) substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); } move(6, 0); - sprintf(genbuf, "�Ш� %s �O ��'f'�ѻP���!\n\n�@�i %d Ptt��, �o�O%s�����\n%s%s", - currboard, - i, i < 100 ? "�p�䦡" : i < 500 ? "������" : - i < 1000 ? "�Q�گ�" : i < 5000 ? "�I����" : "�ɮa����", - bp->endgamble ? "��L�����ɶ�: " : "", - bp->endgamble ? Cdate(&bp->endgamble) : "" - ); + snprintf(genbuf, sizeof(genbuf), + "�Ш� %s �O ��'f'�ѻP���!\n\n�@�i %d Ptt��, �o�O%s�����\n%s%s", + currboard, + i, i < 100 ? "�p�䦡" : i < 500 ? "������" : + i < 1000 ? "�Q�گ�" : i < 5000 ? "�I����" : "�ɮa����", + bp->endgamble ? "��L�����ɶ�: " : "", + bp->endgamble ? Cdate(&bp->endgamble) : "" + ); strcat(msg, genbuf); prints("�Ш̦���J�m���W��, �ݴ���2~8��. (�����K��, ��J������enter)\n"); for (i = 0; i < 8; i++) { - sprintf(yn, " %d)", i + 1); + snprintf(yn, sizeof(yn), " %d)", i + 1); getdata(7 + i, 0, yn, genbuf, 9, DOECHO); if (!genbuf[0] && i > 1) break; @@ -1101,7 +1105,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct) fclose(fp); move(8 + i, 0); prints("��L�]�w����"); - sprintf(genbuf, "[���i] %s �O �}�l���!", currboard); + snprintf(genbuf, sizeof(genbuf), "[���i] %s �O �}�l���!", currboard); post_msg(currboard, genbuf, msg, cuser.userid); post_msg("Record", genbuf + 7, msg, "[�������l]"); /* Tim ����CS, �H�K���b����user���Ƥw�g�g�i�� */ @@ -1146,7 +1150,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct) dirty++; } if (getdata(b_lines - 1, 0, "����G", genbuf, 6, DOECHO)) { - sprintf(tmpfhdr.date, "%.5s", genbuf); + snprintf(tmpfhdr.date, sizeof(tmpfhdr.date), "%.5s", genbuf); dirty++; } } @@ -1223,11 +1227,11 @@ recommend(int ent, fileheader_t * fhdr, char *direct) || yn[0] != 'y') return FULLUPDATE; - sprintf(buf, - "\033[1;31m�� \033[33m%s\033[m\033[33m:%s\033[m%*s���˦�:%s %02d/%02d\n", - cuser.userid, path, - 45 - strlen(cuser.userid) - strlen(path), " ", fromhost, - ptime->tm_mon + 1, ptime->tm_mday); + snprintf(buf, sizeof(buf), + "\033[1;31m�� \033[33m%s\033[m\033[33m:%s\033[m%*s���˦�:%s %02d/%02d\n", + cuser.userid, path, + 45 - strlen(cuser.userid) - strlen(path), " ", fromhost, + ptime->tm_mon + 1, ptime->tm_mday); setdirpath(path, direct, fhdr->filename); log_file(path, buf); if (fhdr->recommend < 9) { @@ -1429,7 +1433,7 @@ tar_addqueue(int ent, fileheader_t * fhdr, char *direct) pressanykey(); return FULLUPDATE; } - sprintf(qfn, BBSHOME "/jobspool/tarqueue.%s", currboard); + snprintf(qfn, sizeof(qfn), BBSHOME "/jobspool/tarqueue.%s", currboard); if (access(qfn, 0) == 0) { outs("�w�g�Ʃw��{, �y��|�i��ƥ�"); pressanykey(); @@ -1699,7 +1703,7 @@ board_select() char genbuf[100]; currmode &= ~MODE_SELECT; - sprintf(fpath, "SR.%s", cuser.userid); + snprintf(fpath, sizeof(fpath), "SR.%s", cuser.userid); setbfile(genbuf, currboard, fpath); unlink(genbuf); if (currstat == RMAIL) @@ -1768,13 +1772,13 @@ good_post(int ent, fileheader_t * fhdr, char *direct) strlcpy(buf, direct, sizeof(buf)); ptr = strrchr(buf, '/') + 1; ptr[0] = '\0'; - sprintf(genbuf, "%s%s", buf, digest.filename); + snprintf(genbuf, sizeof(genbuf), "%s%s", buf, digest.filename); if (dashf(genbuf)) unlink(genbuf); digest.filemode = 0; - sprintf(genbuf2, "%s%s", buf, fhdr->filename); + snprintf(genbuf2, sizeof(genbuf2), "%s%s", buf, fhdr->filename); Link(genbuf2, genbuf); strcpy(ptr, fn_mandex); append_record(buf, &digest, sizeof(digest)); @@ -2008,8 +2012,8 @@ log_board(char *mode, time_t usetime) char buf[256]; if (usetime > 30) { - sprintf(buf, "USE %-20.20s Stay: %5ld (%s) %s", - mode, usetime, cuser.userid, ctime(&now)); + snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s", + mode, usetime, cuser.userid, ctime(&now)); log_file(FN_USEBOARD, buf); } } diff --git a/mbbsd/board.c b/mbbsd/board.c index d6d8c8ea..cbbfea1b 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1,4 +1,4 @@ -/* $Id: board.c,v 1.42 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: board.c,v 1.43 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define BRC_STRLEN 15 /* Length of board name */ #define BRC_MAXSIZE 24576 @@ -328,8 +328,9 @@ have_author(char *brdname) { char dirname[100]; - sprintf(dirname, "���b�j�M�@��[33m%s[m �ݪO:[1;33m%s[0m.....", - currauthor, brdname); + snprintf(dirname, sizeof(dirname), + "���b�j�M�@��[33m%s[m �ݪO:[1;33m%s[0m.....", + currauthor, brdname); move(b_lines, 0); clrtoeol(); outs(dirname); diff --git a/mbbsd/cache.c b/mbbsd/cache.c index fd61cf55..0ceb8376 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -1,4 +1,4 @@ -/* $Id: cache.c,v 1.43 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: cache.c,v 1.44 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #ifndef __FreeBSD__ @@ -42,7 +42,7 @@ safe_sleep(unsigned int seconds) static void setapath(char *buf, char *boardname) { - sprintf(buf, "man/boards/%c/%s", boardname[0], boardname); + snprintf(buf, "man/boards/%c/%s", boardname[0], boardname); } static char *str_dotdir = ".DIR"; @@ -329,8 +329,8 @@ setutmpmode(int mode) /* �l�ܨϥΪ� */ if (HAS_PERM(PERM_LOGUSER)) { char msg[200]; - sprintf(msg, "%s setutmpmode to %s(%d) at %s", - cuser.userid, modestring(currutmp, 0), mode, Cdate(&now)); + snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s", + cuser.userid, modestring(currutmp, 0), mode, Cdate(&now)); log_user(msg); } } @@ -779,7 +779,8 @@ setbtotal(int bid) char genbuf[256]; int num, fd; - sprintf(genbuf, "boards/%c/%s/.DIR", bh->brdname[0], bh->brdname); + snprintf(genbuf, sizeof(genbuf), + "boards/%c/%s/.DIR", bh->brdname[0], bh->brdname); if ((fd = open(genbuf, O_RDWR)) < 0) return; /* .DIR���F */ @@ -892,15 +893,16 @@ reload_pttcache() if ((fp = fopen(buf, "r"))) { while (fread(&item, sizeof(item), 1, fp)) { if (item.title[3] == '<' && item.title[8] == '>') { - sprintf(buf, "%s/%s", pbuf, item.filename); + snprintf(buf, sizeof(buf), "%s/%s", pbuf, item.filename); setadir(buf, buf); if (!(fp1 = fopen(buf, "r"))) continue; SHM->next_refresh[section] = SHM->n_notes[section] = id; section++; while (fread(&subitem, sizeof(subitem), 1, fp1)) { - sprintf(buf, "%s/%s/%s", pbuf, item.filename, - subitem.filename); + snprintf(buf, sizeof(buf), + "%s/%s/%s", pbuf, item.filename, + subitem.filename); if (!(fp2 = fopen(buf, "r"))) continue; fread(SHM->notes[id], sizeof(char), 200 * 11, fp2); diff --git a/mbbsd/cal.c b/mbbsd/cal.c index fb0c2802..ee23879b 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -1,4 +1,4 @@ -/* $Id: cal.c,v 1.18 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: cal.c,v 1.19 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* ���� Multi play */ @@ -63,15 +63,16 @@ vice(int money, char *item) unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100; FILE *fp; demoney(-money); - sprintf(buf, BBSHOME "/home/%c/%s/%s", - cuser.userid[0], cuser.userid, VICE_NEW); + snprintf(buf, sizeof(buf), BBSHOME "/home/%c/%s/%s", + cuser.userid[0], cuser.userid, VICE_NEW); fp = fopen(buf, "a"); if (!fp) { return 0; } fprintf(fp, "%08d\n", viceserial); fclose(fp); - sprintf(buf, "%s ��F%d$ �s��[%08d]", item, money, viceserial); + snprintf(buf, sizeof(buf), + "%s ��F%d$ �s��[%08d]", item, money, viceserial); mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt�g�ٳ�"); return 0; } @@ -117,7 +118,8 @@ osong(char *defaultid) } move(12, 0); clrtobot(); - sprintf(buf, "�˷R�� %s �w��Ө�ڮ�۰��I�q�t��\n", cuser.userid); + snprintf(buf, sizeof(buf), + "�˷R�� %s �w��Ө�ڮ�۰��I�q�t��\n", cuser.userid); outs(buf); trans_buffer[0] = 0; if (!defaultid) { @@ -141,7 +143,8 @@ osong(char *defaultid) } getdata_str(14, 0, "�Q�n�n��L(�o)��..:", say, sizeof(say), DOECHO, "�ڷR�p.."); - sprintf(save_title, "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); + snprintf(save_title, sizeof(save_title), + "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); getdata_str(16, 0, "�H��֪��H�c(�i��E-mail)?", receiver, sizeof(receiver), LCECHO, destid); @@ -167,7 +170,9 @@ osong(char *defaultid) return 0; } strlcpy(mail.owner, "�I�q��", sizeof(mail.owner)); - sprintf(mail.title, "�� %s �I�� %s ", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, destid); + snprintf(mail.title, sizeof(mail.title), + "�� %s �I�� %s ", + (ano[0] == 'y') ? "�ΦW��" : cuser.userid, destid); while (fgets(buf, 200, fp)) { char *po; @@ -182,17 +187,19 @@ osong(char *defaultid) } while ((po = strstr(buf, "<~Src~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, (ano[0] == 'y') ? "�ΦW��" : cuser.userid, po + 7); + snprintf(genbuf, sizeof(genbuf), + "%s%s%s", buf, + (ano[0] == 'y') ? "�ΦW��" : cuser.userid, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } while ((po = strstr(buf, "<~Des~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, destid, po + 7); + snprintf(genbuf, sizeof(genbuf), "%s%s%s", buf, destid, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } while ((po = strstr(buf, "<~Say~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, say, po + 7); + snprintf(genbuf, sizeof(genbuf), "%s%s%s", buf, say, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } fputs(buf, fp1); @@ -212,7 +219,8 @@ osong(char *defaultid) /* ��Ĥ@������ */ vice(200, "�I�q"); } - sprintf(save_title, "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); + snprintf(save_title, sizeof(save_title), + "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); hold_mail(filename, destid); if (receiver[0]) { @@ -304,13 +312,14 @@ p_exmail() int n; if (cuser.exmailbox >= MAX_EXKEEPMAIL) { - sprintf(buf, "�e�q�̦h�W�[ %d �ʡA����A�R�F�C", MAX_EXKEEPMAIL); + snprintf(buf, sizeof(buf), + "�e�q�̦h�W�[ %d �ʡA����A�R�F�C", MAX_EXKEEPMAIL); outs(buf); refresh(); return 0; } - sprintf(buf, "�z���W�� %d �ʮe�q�A�٭n�A�R�h��?", - cuser.exmailbox); + snprintf(buf, sizeof(buf), + "�z���W�� %d �ʮe�q�A�٭n�A�R�h��?", cuser.exmailbox); getdata_str(b_lines - 2, 0, buf, ans, sizeof(ans), LCECHO, "10"); @@ -333,7 +342,7 @@ mail_redenvelop(char *from, char *to, int money, char mode) char genbuf[200]; fileheader_t fhdr; FILE *fp; - sprintf(genbuf, "home/%c/%s", to[0], to); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s", to[0], to); stampfile(genbuf, &fhdr); if (!(fp = fopen(genbuf, "w"))) return; @@ -345,12 +354,12 @@ mail_redenvelop(char *from, char *to, int money, char mode) " §�����N���A�Я���...... ^_^\033[m\n" ,from, ctime(&now), to, money); fclose(fp); - sprintf(fhdr.title, "�۰]�i�_"); + snprintf(fhdr.title, sizeof(fhdr.title), "�۰]�i�_"); strlcpy(fhdr.owner, from, sizeof(fhdr.owner)); if (mode == 'y') vedit(genbuf, NA, NULL); - sprintf(genbuf, "home/%c/%s/.DIR", to[0], to); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s/.DIR", to[0], to); append_record(genbuf, &fhdr, sizeof(fhdr)); } @@ -388,8 +397,8 @@ p_give() return 0; /* ú���|�N�S�����F */ deumoney(searchuser(id), money - tax); demoney(-money); - sprintf(genbuf, "%s\t��%s\t%d\t%s", cuser.userid, id, money - tax, - ctime(&now)); + snprintf(genbuf, sizeof(genbuf), "%s\t��%s\t%d\t%s", + cuser.userid, id, money - tax, ctime(&now)); log_file(FN_MONEY, genbuf); genbuf[0] = 'n'; getdata(3, 0, "�n�ۦ�Ѽg���]�U�ܡH[y/N]", genbuf, 2, LCECHO); @@ -474,7 +483,7 @@ cal() b[0] = '0'; b[1] = 0; move(b_lines - 1, 0); - sprintf(buf, "[%13.2f] [%c] ", a, ch); + snprintf(buf, sizeof(buf), "[%13.2f] [%c] ", a, ch); outs(buf); break; case '.': @@ -495,11 +504,11 @@ cal() if (strlen(b) > 13) break; if (flo || b[0] != '0') - sprintf(b, "%s%c", b, ch); + snprintf(b, sizeof(b), "%s%c", b, ch); else b[0] = ch; move(b_lines - 1, 0); - sprintf(buf, "[%13s] [%c]", b, mode[(int)cmode]); + snprintf(buf, sizeof(buf), "[%13s] [%c]", b, mode[(int)cmode]); outs(buf); break; case 'q': diff --git a/mbbsd/card.c b/mbbsd/card.c index 1c457046..55102df5 100644 --- a/mbbsd/card.c +++ b/mbbsd/card.c @@ -1,4 +1,4 @@ -/* $Id: card.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: card.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static int @@ -372,8 +372,9 @@ card_double_ask() { char buf[100], buf2[3]; - sprintf(buf, "[ %s ]�z�{�b�@�� %d P��, �{�b�n����(�[�� %d ��)��? [y/N]", - cuser.userid, cuser.money, JACK); + snprintf(buf, sizeof(buf), + "[ %s ]�z�{�b�@�� %d P��, �{�b�n����(�[�� %d ��)��? [y/N]", + cuser.userid, cuser.money, JACK); reload_money(); if (cuser.money < JACK) return 0; @@ -388,7 +389,7 @@ card_ask() { char buf[100], buf2[3]; - sprintf(buf, "[ %s ]�z�{�b�@�� %d P��, �٭n�[�P��? [y/N]", + snprintf(buf, sizeof(buf), "[ %s ]�z�{�b�@�� %d P��, �٭n�[�P��? [y/N]", cuser.userid, cuser.money); getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO); if (buf2[0] == 'y' || buf2[0] == 'Y') diff --git a/mbbsd/chat.c b/mbbsd/chat.c index e852fbf2..4c58b290 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -1,4 +1,4 @@ -/* $Id: chat.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: chat.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static int chatline, stop_line; @@ -51,7 +51,7 @@ chat_send(int fd, char *buf) int len; char genbuf[200]; - sprintf(genbuf, "%s\n", buf); + snprintf(genbuf, sizeof(genbuf), "%s\n", buf); len = strlen(genbuf); return (send(fd, genbuf, len, 0) == len); } @@ -94,7 +94,7 @@ chat_recv(int fd, char *chatid) case 't': move(0, 0); clrtoeol(); - sprintf(genbuf, "�ͤѫ� [%s]", chatroom); + snprintf(genbuf, sizeof(genbuf), "�ͤѫ� [%s]", chatroom); prints("\033[1;37;46m %-21s \033[45m ���D�G%-48s\033[m", genbuf, bptr + 2); } @@ -131,9 +131,9 @@ printuserent(userinfo_t * uentp) if (!HAS_PERM(PERM_SYSOP) && !HAS_PERM(PERM_SEECLOAK) && uentp->invisible) return 0; - sprintf(pline, "%-13s%c%-10s ", uentp->userid, - uentp->invisible ? '#' : ' ', - modestring(uentp, 1)); + snprintf(pline, sizeof(pline), "%-13s%c%-10s ", uentp->userid, + uentp->invisible ? '#' : ' ', + modestring(uentp, 1)); if (cnt < 2) strcat(pline, "�x"); strcat(uline, pline); @@ -150,7 +150,7 @@ chathelp(char *cmd, char *desc) { char buf[STRLEN]; - sprintf(buf, " %-20s- %s", cmd, desc); + snprintf(buf, sizeof(buf), " %-20s- %s", cmd, desc); printchatline(buf); } @@ -190,7 +190,8 @@ chat_date() { char genbuf[200]; - sprintf(genbuf, "�� " BBSNAME "�зǮɶ�: %s", Cdate(&now)); + snprintf(genbuf, sizeof(genbuf), + "�� " BBSNAME "�зǮɶ�: %s", Cdate(&now)); printchatline(genbuf); } @@ -200,8 +201,8 @@ chat_pager() char genbuf[200]; char *msgs[] = {"����", "���}", "�ޱ�", "����", "�n��"}; - sprintf(genbuf, "�� �z���I�s��:[%s]", - msgs[currutmp->pager = (currutmp->pager + 1) % 5]); + snprintf(genbuf, sizeof(genbuf), "�� �z���I�s��:[%s]", + msgs[currutmp->pager = (currutmp->pager + 1) % 5]); printchatline(genbuf); } @@ -217,11 +218,13 @@ chat_query(char *arg) char buf[128], *ptr; FILE *fp; - sprintf(buf, "%s(%s) �@�W�� %d ���A�o���L %d �g�峹", - xuser.userid, xuser.username, xuser.numlogins, xuser.numposts); + snprintf(buf, sizeof(buf), "%s(%s) �@�W�� %d ���A�o���L %d �g�峹", + xuser.userid, xuser.username, + xuser.numlogins, xuser.numposts); printchatline(buf); - sprintf(buf, "�̪�(%s)�q[%s]�W��", Cdate(&xuser.lastlogin), + snprintf(buf, sizeof(buf), + "�̪�(%s)�q[%s]�W��", Cdate(&xuser.lastlogin), (xuser.lasthost[0] ? xuser.lasthost : "(����)")); printchatline(buf); @@ -308,8 +311,9 @@ select_address() trans_buffer[0] = 0; if ((fp = fopen("etc/teashop", "r"))) { for (c = 0; fscanf(fp, "%s%s", iptab[c], nametab[c]) != EOF; c++) { - sprintf(buf, "\n (\033[36m%d\033[0m) %-30s [%s]", - c + 1, nametab[c], iptab[c]); + snprintf(buf, sizeof(buf), + "\n (\033[36m%d\033[0m) %-30s [%s]", + c + 1, nametab[c], iptab[c]); outs(buf); } getdata(20, 10, "��\033[32m �п�ܡA[0]���}�G\033[0m", buf, 3, @@ -379,18 +383,19 @@ t_chat() while (1) { getdata(b_lines - 1, 0, "�п�J��ѥN���G", inbuf, 9, DOECHO); - sprintf(chatid, "%s", (inbuf[0] ? inbuf : cuser.userid)); + snprintf(chatid, sizeof(chatid), + "%s", (inbuf[0] ? inbuf : cuser.userid)); chatid[8] = '\0'; /* * �®榡: /! �ϥΪ̽s�� �ϥΪ̵��� UserID ChatID �s�榡: /! * UserID ChatID Password */ if (roomtype == 1) - sprintf(inbuf, "/! %s %s %s", - cuser.userid, chatid, cuser.passwd); + snprintf(inbuf, sizeof(inbuf), "/! %s %s %s", + cuser.userid, chatid, cuser.passwd); else - sprintf(inbuf, "/! %d %d %s %s", - usernum, cuser.userlevel, cuser.userid, chatid); + snprintf(inbuf, sizeof(inbuf), "/! %d %d %s %s", + usernum, cuser.userlevel, cuser.userid, chatid); chat_send(cfd, inbuf); if (recv(cfd, inbuf, 3, 0) != 3) return 0; diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c index e42a2a5a..4744141e 100644 --- a/mbbsd/chicken.c +++ b/mbbsd/chicken.c @@ -1,4 +1,4 @@ -/* $Id: chicken.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: chicken.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define NUM_KINDS 13 /* ���h�ֺذʪ� */ @@ -128,9 +128,10 @@ new_chicken() getdata(8, 0, "���e���Ӧn�W�r�G", mychicken->name, sizeof(mychicken->name), DOECHO); - sprintf(buf, "\033[31m%s \033[m�i�F�@���s\033[33m %s \033[m�� " - "\033[32m%s\033[m �� %s", cuser.userid, - mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); + snprintf(buf, sizeof(buf), + "\033[31m%s \033[m�i�F�@���s\033[33m %s \033[m�� " + "\033[32m%s\033[m �� %s", cuser.userid, + mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); log_file(CHICKENLOG, buf); mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now; mychicken->food = 0; @@ -219,8 +220,8 @@ show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken) show_chicken_stat(thechicken); - sprintf(buf, CHICKEN_PIC "/%c%d", thechicken->type + 'a', - age > 16 ? 16 : age); + snprintf(buf, sizeof(buf), CHICKEN_PIC "/%c%d", thechicken->type + 'a', + age > 16 ? 16 : age); show_file(buf, 5, 14, NO_RELOAD); move(18, 0); @@ -424,16 +425,17 @@ ch_kill() { char buf[150], ans[4]; - sprintf(buf, "��i�o%s�n�Q�@ 100 ��, �O�_�n��i?(y/N)", + snprintf(buf, sizeof(buf), "��i�o%s�n�Q�@ 100 ��, �O�_�n��i?(y/N)", chicken_type[(int)mychicken->type]); getdata_str(23, 0, buf, ans, sizeof(ans), DOECHO, "N"); if (ans[0] == 'y') { vice(100, "��i�d���O"); more(CHICKEN_PIC "/deadth", YEA); - sprintf(buf, "\033[31m%s \033[m�� \033[33m%s\033[m\033[32m %s " - "\033[m�_�F �� %s", cuser.userid, - mychicken->name, chicken_type[(int)mychicken->type], ctime(&now)); + snprintf(buf, sizeof(buf), + "\033[31m%s \033[m�� \033[33m%s\033[m\033[32m %s " + "\033[m�_�F �� %s", cuser.userid, mychicken->name, + chicken_type[(int)mychicken->type], ctime(&now)); log_file(CHICKENLOG, buf); mychicken->name[0] = 0; } @@ -485,11 +487,11 @@ ch_sell() pressanykey(); return 0; } - sprintf(buf, "�o��%d��%s�i�H�� %d ��, �O�_�n��?(y/N)", age, - chicken_type[(int)mychicken->type], money); + snprintf(buf, sizeof(buf), "�o��%d��%s�i�H�� %d ��, �O�_�n��?(y/N)", age, + chicken_type[(int)mychicken->type], money); getdata_str(23, 0, buf, ans, sizeof(ans), DOECHO, "N"); if (ans[0] == 'y') { - sprintf(buf, "\033[31m%s\033[m �� \033[33m%s\033[m " + snprintf(buf, sizeof(buf), "\033[31m%s\033[m �� \033[33m%s\033[m " "\033[32m%s\033[m �� \033[36m%d\033[m ��F �� %s", cuser.userid, mychicken->name, chicken_type[(int)mychicken->type], money, ctime(&now)); @@ -645,11 +647,12 @@ deadtype(chicken_t * thechicken) return 0; if (thechicken == mychicken) { - sprintf(buf, "\033[31m%s\033[m �үk�R��\033[33m %s\033[32m %s " - "\033[m���F �� %s", - cuser.userid, thechicken->name, - chicken_type[(int)thechicken->type], - ctime(&now)); + snprintf(buf, sizeof(buf), + "\033[31m%s\033[m �үk�R��\033[33m %s\033[32m %s " + "\033[m���F �� %s", + cuser.userid, thechicken->name, + chicken_type[(int)thechicken->type], + ctime(&now)); log_file(CHICKENLOG, buf); mychicken->name[0] = 0; passwd_update(usernum, &cuser); @@ -702,11 +705,12 @@ ch_changename() mychicken->name); if (strlen(newname) >= 3 && strcmp(newname, mychicken->name)) { - sprintf(buf, "\033[31m%s\033[m ��k�R��\033[33m %s\033[32m %s " - "\033[m��W��\033[33m %s\033[m �� %s", - cuser.userid, mychicken->name, - chicken_type[(int)mychicken->type], - newname, ctime(&now)); + snprintf(buf, sizeof(buf), + "\033[31m%s\033[m ��k�R��\033[33m %s\033[32m %s " + "\033[m��W��\033[33m %s\033[m �� %s", + cuser.userid, mychicken->name, + chicken_type[(int)mychicken->type], + newname, ctime(&now)); strlcpy(mychicken->name, newname, sizeof(mychicken->name)); log_file(CHICKENLOG, buf); } @@ -815,9 +819,9 @@ recover_chicken(chicken_t * thechicken) "�̪�ʿ��Q�ȥ~�� \033[m"); bell(); igetch(); - sprintf(buf, "\033[33;44m���F�ɦu��\033[37;45m " - "�A���@�ӭ訫���[��%s�n�۴��^�Ӷ�? �u�n%d���� \033[m", - chicken_type[(int)thechicken->type], price * 2); + snprintf(buf, sizeof(buf), "\033[33;44m���F�ɦu��\033[37;45m " + "�A���@�ӭ訫���[��%s�n�۴��^�Ӷ�? �u�n%d���� \033[m", + chicken_type[(int)thechicken->type], price * 2); outmsg(buf); bell(); getdata_str(21, 0, " ��ܡG(N:�|�H��/y:��������)", buf, 3, LCECHO, "N"); @@ -835,8 +839,9 @@ recover_chicken(chicken_t * thechicken) thechicken->sick = 0; thechicken->satis = 2; vice(money, "�F�ɦu��"); - sprintf(buf, "\033[33;44m���F�ɦu��\033[37;45m OK�F �O�o���L�I�F�� " - "���M�i�ॢ�� ���b�ڤ]����Ptt ���A%d�N�n \033[m", money); + snprintf(buf, sizeof(buf), + "\033[33;44m���F�ɦu��\033[37;45m OK�F �O�o���L�I�F�� " + "���M�i�ॢ�� ���b�ڤ]����Ptt ���A%d�N�n \033[m", money); outmsg(buf); bell(); igetch(); @@ -949,8 +954,8 @@ chickenpk(int fd) switch (ch) { case 'y': if (catched == 1) { - sprintf(data, "l�� %s ���]�F\n", - ochicken->name); + snprintf(data, sizeof(data), + "l�� %s ���]�F\n", ochicken->name); } break; case 'n': @@ -959,13 +964,15 @@ chickenpk(int fd) case 'k': r = r % (attmax + 2); if (r) { - sprintf(data, "M%s %s%s %s �ˤF %d �I\n", mychicken->name, - damage_degree[r / 3 > 15 ? 15 : r / 3], - attack_type[(int)mychicken->type], - ochicken->name, r); + snprintf(data, sizeof(data), + "M%s %s%s %s �ˤF %d �I\n", mychicken->name, + damage_degree[r / 3 > 15 ? 15 : r / 3], + attack_type[(int)mychicken->type], + ochicken->name, r); ochicken->hp -= r; } else - sprintf(data, "M%s ı�o��n�X���L��\n", mychicken->name); + snprintf(data, sizeof(data), + "M%s ı�o��n�X���L��\n", mychicken->name); break; case 'o': if (mychicken->oo > 0) { @@ -974,26 +981,28 @@ chickenpk(int fd) if (mychicken->hp > mychicken->hp_max) mychicken->hp = mychicken->hp_max; mychicken->tiredstrong = 0; - sprintf(data, "M%s �Y�F���j�ɤY�ɥR��O\n", - mychicken->name); + snprintf(data, sizeof(data), "M%s �Y�F���j�ɤY�ɥR��O\n", + mychicken->name); } else - sprintf(data, "M%s �Q�Y�j�ɤY, �i�O�S���j�ɤY�i�Y\n", + snprintf(data, sizeof(data), + "M%s �Q�Y�j�ɤY, �i�O�S���j�ɤY�i�Y\n", mychicken->name); break; case 'q': if (r % (mychicken->run + 1) > r % (ochicken->run + 1)) - sprintf(data, "q%s ���]�F\n", - mychicken->name); + snprintf(data, sizeof(data), "q%s ���]�F\n", + mychicken->name); else - sprintf(data, "c%s �Q���], ���Q %s ���F\n", - mychicken->name, ochicken->name); + snprintf(data, sizeof(data), + "c%s �Q���], ���Q %s ���F\n", + mychicken->name, ochicken->name); break; } if (deadtype(ochicken)) { strtok(data, "\n"); strlcpy(buf, data, sizeof(buf)); - sprintf(data, "d%s , %s �Q %s �����F\n", - buf + 1, ochicken->name, mychicken->name); + snprintf(data, sizeof(data), "d%s , %s �Q %s �����F\n", + buf + 1, ochicken->name, mychicken->name); } move(17, 0); outs(data + 1); diff --git a/mbbsd/dark.c b/mbbsd/dark.c index cd37fd0b..4c9c6486 100644 --- a/mbbsd/dark.c +++ b/mbbsd/dark.c @@ -1,4 +1,4 @@ -/* $Id: dark.c,v 1.7 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: dark.c,v 1.8 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define RED 1 @@ -156,14 +156,14 @@ draw_line(sint y, sint f) strlcpy(buf, "\033[43;30m", sizeof(buf)); for (i = 0; i < 8; i++) { if (brd[y][i].die == 1) - sprintf(tmp, "�x "); + snprintf(tmp, sizeof(tmp), "�x "); else if (brd[y][i].out == 0) - sprintf(tmp, "�x��"); + snprintf(tmp, sizeof(tmp), "�x��"); else { - sprintf(tmp, "�x\033[%s1;%dm%s\033[m\033[43;30m", - (f == i) ? "1;47;" : "", (brd[y][i].color) ? 31 : 34, - (brd[y][i].color) ? rname[brd[y][i].value] : - bname[brd[y][i].value]); + snprintf(tmp, sizeof(tmp), "�x\033[%s1;%dm%s\033[m\033[43;30m", + (f == i) ? "1;47;" : "", (brd[y][i].color) ? 31 : 34, + (brd[y][i].color) ? rname[brd[y][i].value] : + bname[brd[y][i].value]); } strcat(buf, tmp); } diff --git a/mbbsd/dice.c b/mbbsd/dice.c index 69d7486f..fae9d262 100644 --- a/mbbsd/dice.c +++ b/mbbsd/dice.c @@ -1,4 +1,4 @@ -/* $Id: dice.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: dice.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define DICE_TXT BBSHOME "/etc/dice.txt" @@ -454,9 +454,10 @@ dice_main(void) demoney(table[j].mymoney * ya + table[j].mymoney); total += table[j].mymoney * ya; if (table[j].mymoney * ya > 500) { /* �W�L500�����~��log ���io */ - sprintf(data, "%-15s ��%-2d�ﶵ%-8d���� ���F%d�� �b��:%-8d\n", - cuser.userid, table[j].mybet, - table[j].mymoney, ya, table[j].mymoney * ya); + snprintf(data, sizeof(data), + "%-15s ��%-2d�ﶵ%-8d���� ���F%d�� �b��:%-8d\n", + cuser.userid, table[j].mybet, + table[j].mymoney, ya, table[j].mymoney * ya); fputs(data, winfp); } ya = 0; 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) } /* �s��240��interval�@�� , �����O�b�İ] */ if (count >= 240) { - sprintf(buf, "\033[1;33;46m%s\033[37m�b\033[37;45m%s" + snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m�b\033[37;45m%s" "\033[37m�O�H�k�ȿ� , %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); diff --git a/mbbsd/friend.c b/mbbsd/friend.c index 6029bfd8..2df2025b 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -1,4 +1,4 @@ -/* $Id: friend.c,v 1.11 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: friend.c,v 1.12 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* ------------------------------------- */ @@ -114,7 +114,7 @@ friend_special() friend_file[FRIEND_SPECIAL] = special_list; for (i = 0; i <= 9; i++) { - sprintf(genbuf, " (\033[36m%d\033[m) .. ", i); + snprintf(genbuf, sizeof(genbuf), " (\033[36m%d\033[m) .. ", i); special_des[5] = i + '0'; setuserfile(fname, special_des); if (dashf(fname)) { @@ -153,15 +153,17 @@ friend_append(int type, int count) for (j = i = 0; i <= 4; i++) if (i != type) { ++j; - sprintf(buf, " (%d) %-s\n", i + 1, friend_list[(int)i]); + snprintf(buf, sizeof(buf), + " (%d) %-s\n", i + 1, friend_list[(int)i]); outs(buf); } if (HAVE_PERM(PERM_SYSOP) || currmode & MODE_BOARD) for (; i < 8; ++i) if (i != type) { ++j; - sprintf(buf, " (%d) %s �O�� %s\n", j, currboard, - friend_list[(int)i]); + snprintf(buf, sizeof(buf), + " (%d) %s �O�� %s\n", j, currboard, + friend_list[(int)i]); outs(buf); } outs(" (S) ��ܨ�L�ݪO���S�O�W��"); @@ -229,7 +231,7 @@ friend_editdesc(char *uident, int type) FILE *fp, *nfp; char fnnew[200], genbuf[200], fn[200]; setfriendfile(fn, type); - sprintf(fnnew, "%s-", fn); + snprintf(fnnew, sizeof(fnnew), "%s-", fn); if ((fp = fopen(fn, "r")) && (nfp = fopen(fnnew, "w"))) { int length = strlen(uident); @@ -324,7 +326,8 @@ friend_edit(int type) if (type == FRIEND_ALOHA || type == FRIEND_POST) { if (dashf(fpath)) { - sprintf(genbuf, "/bin/cp %s %s.old", fpath, fpath); + snprintf(genbuf, sizeof(genbuf), + "/bin/cp %s %s.old", fpath, fpath); system(genbuf); } } @@ -332,7 +335,7 @@ friend_edit(int type) while (1) { stand_title(friend_list[type]); move(0, 40); - sprintf(line, "(�W��W��:%d�ӤH)", friend_max[type]); + snprintf(line, sizeof(line), "(�W��W��:%d�ӤH)", friend_max[type]); outs(line); count = 0; CreateNameList(); @@ -406,7 +409,7 @@ friend_edit(int type) outs("��s��Ƥ�..�еy��....."); refresh(); if (type == FRIEND_ALOHA || type == FRIEND_POST) { - sprintf(genbuf, "%s.old", fpath); + snprintf(genbuf, sizeof(genbuf), "%s.old", fpath); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { sscanf(line, "%s", uident); @@ -416,7 +419,7 @@ friend_edit(int type) } fclose(fp); } - sprintf(genbuf, "%s", fpath); + snprintf(genbuf, sizeof(genbuf), "%s", fpath); if ((fp = fopen(genbuf, "r"))) { while (fgets(line, 80, fp)) { sscanf(line, "%s", uident); diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 97961898..836dbc25 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -1,4 +1,4 @@ -/* $Id: gamble.c,v 1.27 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: gamble.c,v 1.28 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #ifndef _BBS_UTIL_C_ @@ -18,7 +18,7 @@ post_msg(char *bname, char *title, char *msg, char *author) char genbuf[256]; /* �b bname �O�o���s�峹 */ - sprintf(genbuf, "boards/%c/%s", bname[0], bname); + snprintf(genbuf, sizeof(genbuf), "boards/%c/%s", bname[0], bname); stampfile(genbuf, &fhdr); fp = fopen(genbuf, "w"); @@ -69,7 +69,7 @@ load_ticket_record(char *direct, int ticket[]) char buf[256]; int i, total = 0; FILE *fp; - sprintf(buf, "%s/" FN_TICKET_RECORD, direct); + snprintf(buf, sizeof(buf), "%s/" FN_TICKET_RECORD, direct); if (!(fp = fopen(buf, "r"))) return 0; for (i = 0; i < MAX_ITEM && fscanf(fp, "%9d ", &ticket[i]); i++) @@ -87,19 +87,21 @@ show_ticket_data(char *direct, int *price, boardheader_t * bh) clear(); if (bh) { - sprintf(genbuf, "%s ��L", bh->brdname); - if (bh->endgamble && now < bh->endgamble && bh->endgamble - now < 3600) { - sprintf(t, "�ʽL�˼� %d ��", (int)(bh->endgamble - now)); + snprintf(genbuf, sizeof(genbuf), "%s ��L", bh->brdname); + if (bh->endgamble && now < bh->endgamble && + bh->endgamble - now < 3600) { + snprintf(t, sizeof(t), + "�ʽL�˼� %d ��", (int)(bh->endgamble - now)); showtitle(genbuf, t); } else showtitle(genbuf, BBSNAME); } else showtitle("Ptt��L", BBSNAME); move(2, 0); - sprintf(genbuf, "%s/" FN_TICKET_ITEMS, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_ITEMS, direct); if (!(fp = fopen(genbuf, "r"))) { prints("\n�ثe�èS���|���L\n"); - sprintf(genbuf, "%s/" FN_TICKET_OUTCOME, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_OUTCOME, direct); if (more(genbuf, NA)); return 0; } @@ -121,9 +123,9 @@ show_ticket_data(char *direct, int *price, boardheader_t * bh) bh ? "�O�D�ۭq�W�h�λ���" : "�e�X���}�����G"); - sprintf(genbuf, "%s/" FN_TICKET, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET, direct); if (!dashf(genbuf)) { - sprintf(genbuf, "%s/" FN_TICKET_END, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_END, direct); end = 1; } show_file(genbuf, 8, -1, NO_RELOAD); @@ -152,7 +154,7 @@ append_ticket_record(char *direct, int ch, int n, int count) FILE *fp; int ticket[8] = {0, 0, 0, 0, 0, 0, 0, 0}, i; char genbuf[256]; - sprintf(genbuf, "%s/" FN_TICKET_USER, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_USER, direct); if ((fp = fopen(genbuf, "a"))) { fprintf(fp, "%s %d %d\n", cuser.userid, ch, n); @@ -160,7 +162,7 @@ append_ticket_record(char *direct, int ch, int n, int count) } load_ticket_record(direct, ticket); ticket[ch] += n; - sprintf(genbuf, "%s/" FN_TICKET_RECORD, direct); + snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_RECORD, direct); if ((fp = fopen(genbuf, "w"))) { for (i = 0; i < count; i++) fprintf(fp, "%d ", ticket[i]); @@ -343,11 +345,12 @@ openticket(int bid) if (bet == 98 && mybet >= 0 && mybet < count) { fprintf(fp, "%s �R�F %d �i %s, �h�^ %d �T��\n" ,userid, i, betname[mybet], money); - sprintf(buf, "%s ����h��! $ %d", bh->brdname, money * i); + snprintf(buf, sizeof(buf), + "%s ����h��! $ %d", bh->brdname, money * i); } else if (mybet == bet) { fprintf(fp, "���� %s �R�F%d �i %s, ��o %d �T��\n" ,userid, i, betname[mybet], money); - sprintf(buf, "%s ������! $ %d", bh->brdname, money * i); + snprintf(buf, sizeof(buf), "%s ������! $ %d", bh->brdname, money * i); } else continue; if ((uid = searchuser(userid)) == 0) @@ -360,9 +363,9 @@ openticket(int bid) fclose(fp); if (bet != 98) - sprintf(buf, "[���i] %s ��L�}��", bh->brdname); + snprintf(buf, sizeof(buf), "[���i] %s ��L�}��", bh->brdname); else - sprintf(buf, "[���i] %s ��L����", bh->brdname); + snprintf(buf, sizeof(buf), "[���i] %s ��L����", bh->brdname); post_file(bh->brdname, buf, outcome, "[�䯫]"); post_file("Record", buf + 7, outcome, "[�������l]"); diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index c6870e3f..7822b090 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -1,4 +1,4 @@ -/* $Id: gomo.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: gomo.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static char *chess[] = {"��", "��"}; @@ -53,8 +53,8 @@ HO_log(char *user) Horder_t *ptr = pool; fileheader_t mymail; - sprintf(buf, "home/%c/%s/F.%d", cuser.userid[0], cuser.userid, - rand() & 65535); + snprintf(buf, sizeof(buf), "home/%c/%s/F.%d", + cuser.userid[0], cuser.userid, rand() & 65535); log = fopen(buf, "w"); for (i = 1; i < 17; i++) @@ -73,8 +73,8 @@ HO_log(char *user) mymail.filemode = FILE_READ | FILE_HOLD; strlcpy(mymail.owner, "[��.��.��]", sizeof(mymail.owner)); - sprintf(mymail.title, "\033[37;41m����\033[m %s VS %s", - cuser.userid, user); + snprintf(mymail.title, sizeof(mymail.title), + "\033[37;41m����\033[m %s VS %s", cuser.userid, user); sethomedir(title, cuser.userid); Rename(buf, buf1); append_record(title, &mymail, sizeof(mymail)); diff --git a/mbbsd/guess.c b/mbbsd/guess.c index 654f45dc..0d655108 100644 --- a/mbbsd/guess.c +++ b/mbbsd/guess.c @@ -1,4 +1,4 @@ -/* $Id: guess.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: guess.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define LOGPASS BBSHOME "/etc/winguess.log" @@ -116,8 +116,8 @@ result(int correct, int number) char a = 0, b = 0, i, j; char n1[5], n2[5]; - sprintf(n1, "%04d", correct); - sprintf(n2, "%04d", number); + snprintf(n1, sizeof(n1), "%04d", correct); + snprintf(n2, sizeof(n2), "%04d", number); for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) if (n1[(int)i] == n2[(int)j]) @@ -136,7 +136,7 @@ legal(int number) char i, j; char temp[5]; - sprintf(temp, "%04d", number); + snprintf(temp, sizeof(temp), "%04d", number); for (i = 0; i < 4; i++) for (j = i + 1; j < 4; j++) if (temp[(int)i] == temp[(int)j]) @@ -173,12 +173,12 @@ computer(int correct, int total, char flag[], int n[]) k = result(correct, guess); if (k == 40) { move(total + 8, 25); - sprintf(data, "%04d", guess); + snprintf(data, sizeof(data), "%04d", guess); prints("%s => �q���F!!", data); return 1; } else { move(total + 8, 25); - sprintf(data, "%04d", guess); + snprintf(data, sizeof(data), "%04d", guess); prints("%s => \033[1;32m%dA %dB\033[m", data, k / 10, k % 10); } j = 0; diff --git a/mbbsd/indict.c b/mbbsd/indict.c index 13030880..7eed0828 100644 --- a/mbbsd/indict.c +++ b/mbbsd/indict.c @@ -1,4 +1,4 @@ -/* $Id: indict.c,v 1.7 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: indict.c,v 1.8 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define REFER "etc/dicts" @@ -19,7 +19,7 @@ addword(char word[]) clear(); move(4, 0); outs(" \033[31mĵ�i\033[m:�Y�W�N��g����ƱN\033[36m��id\033[m�B��\n"); - sprintf(temp, "\n��J�d�Q\n:\033[33m%s\033[m", buf); + snprintf(temp, sizeof(temp), "\n��J�d�Q\n:\033[33m%s\033[m", buf); outs(temp); outs("\n�Ш̤W�C�d�ҿ�J�@����(����enter���)\n"); getdata(10, 0, ":", buf, 65, DOECHO); @@ -47,7 +47,7 @@ choose_dict(void) if ((fp = fopen(REFER, "r"))) { for (c = 0; fscanf(fp, "%s %s", buf[c], data[c]) != EOF; c++) { - sprintf(cho, "\n " + snprintf(cho, sizeof(cho), "\n " "(\033[36m%d\033[m) %-20s�j�r��", c + 1, buf[c]); outs(cho); } @@ -94,15 +94,18 @@ use_dict() clear(); - sprintf(buf, "\033[45m ��\033[1;44;33m" - " %-14s\033[3;45m �� ", dict); + snprintf(buf, sizeof(buf), + "\033[45m ��\033[1;44;33m" + " %-14s\033[3;45m �� ", dict); strlcpy(&buf[100], "\033[m\n", sizeof(buf) - 100); for (;;) { move(0, 0); - sprintf(lang, " �п�J����r��(%s) �Ϋ��O(h,t,a)\n", dict); + snprintf(lang, sizeof(lang), + " �п�J����r��(%s) �Ϋ��O(h,t,a)\n", dict); outs(lang); - sprintf(lang, "[\033[32m<����r>\033[m|\033[32mh\033[m:help|\033[32m" - "t\033[m:�Ҧ����|\033[32ma\033[m:�s�W���%s]\n:", sys); + snprintf(lang, sizeof(lang), + "[\033[32m<����r>\033[m|\033[32mh\033[m:help|\033[32m" + "t\033[m:�Ҧ����|\033[32ma\033[m:�s�W���%s]\n:", sys); outs(lang); getdata(2, 0, ":", word, 18, DOECHO); outs("��Ʒj�M���еy��...."); @@ -1,4 +1,4 @@ -/* $Id: io.c,v 1.21 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: io.c,v 1.22 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #if defined(linux) @@ -474,7 +474,7 @@ oldgetdata(int line, int col, char *prompt, char *buf, int len, int echo) buf[0] = ch | 32; #ifdef SUPPORT_GB if (echo == DOECHO && current_font_type == TYPE_GB) { - strlcpy(buf, hc_convert_str(buf, HC_GBtoBIG, HC_DO_SINGLE), SIZEOF(buf)); + strcpy(buf, hc_convert_str(buf, HC_GBtoBIG, HC_DO_SINGLE)); } #endif return clen; diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 41b927c1..b5c1a25e 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -1,4 +1,4 @@ -/* $Id: kaede.c,v 1.11 2002/07/21 09:33:34 in2 Exp $ */ +/* $Id: kaede.c,v 1.12 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" char * @@ -67,7 +67,7 @@ Rename(char *src, char *dst) if (!strchr(src, ';') && !strchr(dst, ';')) //Ptt � ������`���O { - sprintf(buf, "/bin/mv %s %s", src, dst); + snprintf(buf, sizeof(buf), "/bin/mv %s %s", src, dst); system(buf); } return -1; @@ -83,7 +83,7 @@ Link(char *src, char *dst) if (symlink(dst, src) == 0) return 0; - sprintf(cmd, "/bin/cp -R %s %s", src, dst); + snprintf(cmd, sizeof(cmd), "/bin/cp -R %s %s", src, dst); return system(cmd); } @@ -94,7 +94,8 @@ my_ctime(const time_t * t) static char ans[100]; tp = localtime(t); - sprintf(ans, "%02d/%02d/%02d %02d:%02d:%02d", (tp->tm_year % 100), - tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); + snprintf(ans, sizeof(ans), + "%02d/%02d/%02d %02d:%02d:%02d", (tp->tm_year % 100), + tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); return ans; } diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c index 0ab78aa4..47370524 100644 --- a/mbbsd/lovepaper.c +++ b/mbbsd/lovepaper.c @@ -1,4 +1,4 @@ -/* $Id: lovepaper.c,v 1.9 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: lovepaper.c,v 1.10 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define DATA "etc/lovepaper.dat" @@ -14,7 +14,7 @@ x_love() setutmpmode(LOVE); gtime = localtime(&now); - sprintf(buf1, "%c/%s/love%d%d", + snprintf(buf1, sizeof(buf1), "%c/%s/love%d%d", cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min); strcat(path, buf1); move(1, 0); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index d5426163..786d3151 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1,4 +1,4 @@ -/* $Id: mail.c,v 1.21 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: mail.c,v 1.22 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" char currmaildir[32]; static char msg_cc[] = "\033[32m[�s�զW��]\033[m\n"; @@ -52,8 +52,9 @@ built_mail_index() if (genbuf[0] != 'y') return 0; - sprintf(genbuf, BBSHOME "/bin/buildir " BBSHOME "/home/%c/%s", - cuser.userid[0], cuser.userid); + snprintf(genbuf, sizeof(genbuf), + BBSHOME "/bin/buildir " BBSHOME "/home/%c/%s", + cuser.userid[0], cuser.userid); move(22, 0); prints("\033[1;31m�w�g�B�z����!! �Ѧh���K �q�Э��~\033[m"); pressanykey(); @@ -198,7 +199,7 @@ do_hold_mail(char *fpath, char *receiver, char *holder) mymail.filemode = FILE_READ | FILE_HOLD; strlcpy(mymail.owner, "[��.��.��]", sizeof(mymail.owner)); if (receiver) { - sprintf(title, "(%s) %s", receiver, save_title); + snprintf(title, sizeof(title), "(%s) %s", receiver, save_title); strncpy(mymail.title, title, TTLEN); } else strlcpy(mymail.title, save_title, sizeof(mymail.title)); @@ -463,7 +464,7 @@ multi_send(char *title) do_reply_title(2, title); else { getdata(2, 0, "�D�D�G", fpath, sizeof(fpath), DOECHO); - sprintf(save_title, "[�q�i] %s", fpath); + snprintf(save_title, sizeof(save_title), "[�q�i] %s", fpath); } setuserfile(fpath, fn_notes); @@ -569,7 +570,8 @@ mail_all() stand_title("���Ҧ��ϥΪ̪��t�γq�i"); setutmpmode(SMAIL); getdata(2, 0, "�D�D�G", fpath, sizeof(fpath), DOECHO); - sprintf(save_title, "[�t�γq�i]\033[1;32m %s\033[m", fpath); + snprintf(save_title, sizeof(save_title), + "[�t�γq�i]\033[1;32m %s\033[m", fpath); setuserfile(fpath, fn_notes); @@ -627,7 +629,8 @@ mail_all() sethomedir(genbuf, userid); if (append_record(genbuf, &mymail, sizeof(mymail)) == -1) outs(err_uid); - sprintf(genbuf, "%*s %5d / %5d", IDLEN + 1, userid, i + 1, unum); + snprintf(genbuf, sizeof(genbuf), + "%*s %5d / %5d", IDLEN + 1, userid, i + 1, unum); outmsg(genbuf); refresh(); } @@ -641,8 +644,8 @@ mail_mbox() char cmd[100]; fileheader_t fhdr; - sprintf(cmd, "/tmp/%s.uu", cuser.userid); - sprintf(fhdr.title, "%s �p�H���", cuser.userid); + snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser.userid); + snprintf(fhdr.title, sizeof(fhdr.title), "%s �p�H���", cuser.userid); doforward(cmd, &fhdr, 'Z'); return 0; } @@ -659,7 +662,7 @@ m_forward(int ent, fileheader_t * fhdr, char *direct) strlcpy(quote_user, fhdr->owner, sizeof(quote_user)); setuserfile(quote_file, fhdr->filename); - sprintf(save_title, "%.64s (fwd)", fhdr->title); + snprintf(save_title, sizeof(save_title), "%.64s (fwd)", fhdr->title); move(1, 0); clrtobot(); prints("��H��: %s\n�� �D: %s\n", uid, save_title); @@ -805,17 +808,19 @@ mailtitle() char buf[256] = ""; showtitle("\0�l����", BBSName); - sprintf(buf, "[��]���}[����]���[��]�\\Ū�H�� [R]�^�H [x]��F " - "[y]�s�զ^�H [O]���~�H:%s [h]�D�U\n\033[7m" - "�s�� �� �� �@ �� �H �� �� �D \033[32m", - HAS_PERM(PERM_NOOUTMAIL) ? "\033[31m��\033[m" : "�}"); + snprintf(buf, sizeof(buf), + "[��]���}[����]���[��]�\\Ū�H�� [R]�^�H [x]��F " + "[y]�s�զ^�H [O]���~�H:%s [h]�D�U\n\033[7m" + "�s�� �� �� �@ �� �H �� �� �D \033[32m", + HAS_PERM(PERM_NOOUTMAIL) ? "\033[31m��\033[m" : "�}"); outs(buf); buf[0] = 0; if (mailsumlimit) { - sprintf(buf, "(�e�q:%d/%dk %d/%d�g)", mailsum, mailsumlimit, - mailkeep, mailmaxkeep); + snprintf(buf, sizeof(buf), + "(�e�q:%d/%dk %d/%d�g)", mailsum, mailsumlimit, + mailkeep, mailmaxkeep); } - sprintf(buf, "%s%*s\033[m", buf, 29 - (int)strlen(buf), ""); + snprintf(buf, sizeof(buf), "%s%*s\033[m", buf, 29 - (int)strlen(buf), ""); outs(buf); } @@ -1134,11 +1139,11 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct) } } if (ent) - sprintf(xtitle, "[���]%.66s", fhdr->title); + snprintf(xtitle, sizeof(xtitle), "[���]%.66s", fhdr->title); else strlcpy(xtitle, fhdr->title, sizeof(xtitle)); - sprintf(genbuf, "�ĥέ���D�m%.60s�n��?[Y] ", xtitle); + snprintf(genbuf, sizeof(genbuf), "�ĥέ���D�m%.60s�n��?[Y] ", xtitle); getdata(2, 0, genbuf, genbuf2, sizeof(genbuf2), LCECHO); if (*genbuf2 == 'n') if (getdata(2, 0, "���D�G", genbuf, TTLEN, DOECHO)) @@ -1202,7 +1207,7 @@ mail_man() int stat0 = currstat; sethomeman(buf, cuser.userid); - sprintf(buf1, "%s ���H��", cuser.userid); + snprintf(buf1, sizeof(buf1), "%s ���H��", cuser.userid); a_menu(buf1, buf, 1); currutmp->mode = mode0; currstat = stat0; @@ -1294,7 +1299,7 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct) "�t�αN�|���өM���P�H�᪺���y�U�ۿW��\n" "����I���ɭ� (�y�W�ɬq���~) �N��ƾ�z�n�H�e���z\n\n\n"); if (address[0]) { - sprintf(genbuf, "�H�� [%s] ��(Y/N/Q)�H[Y] ", address); + snprintf(genbuf, sizeof(genbuf), "�H�� [%s] ��(Y/N/Q)�H[Y] ", address); getdata(b_lines - 5, 0, genbuf, fname, 3, LCECHO); if (fname[0] == 'q') { outmsg("�����B�z"); @@ -1315,7 +1320,7 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct) if (invalidaddr(address)) return -2; - //sprintf(fname, "%d\n", cmode); + //snprintf(fname, sizeof(fname), "%d\n", cmode); move(b_lines - 4, 0); outs("�t�δ��Ѩ�ؼҦ�: \n" "�Ҧ� 0: ��²�Ҧ�, �N���t�C�ⱱ��X, ��K�H�¤�r�s�边��z����\n" @@ -1327,14 +1332,14 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct) } cmode = (fname[0] != '0' && fname[0] != '1') ? 1 : fname[0] - '0'; - sprintf(fname, BBSHOME "/jobspool/water.src.%s-%d", - cuser.userid, (int)now); - sprintf(genbuf, "cp " BBSHOME "/home/%c/%s/%s %s", - cuser.userid[0], cuser.userid, fhdr->filename, fname); + snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.src.%s-%d", + cuser.userid, (int)now); + snprintf(genbuf, sizeof(genbuf), "cp " BBSHOME "/home/%c/%s/%s %s", + cuser.userid[0], cuser.userid, fhdr->filename, fname); system(genbuf); /* dirty code ;x */ - sprintf(fname, BBSHOME "/jobspool/water.des.%s-%d", - cuser.userid, (int)now); + snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.des.%s-%d", + cuser.userid, (int)now); fp = fopen(fname, "wt"); fprintf(fp, "%s\n%s\n%d\n", cuser.userid, address, cmode); fclose(fp); @@ -1458,11 +1463,13 @@ bbs_sendmail(char *fpath, char *title, char *receiver) } /* Running the sendmail */ if (fpath == NULL) { - sprintf(genbuf, "/usr/sbin/sendmail %s > /dev/null", receiver); + snprintf(genbuf, sizeof(genbuf), + "/usr/sbin/sendmail %s > /dev/null", receiver); fin = fopen("etc/confirm", "r"); } else { - sprintf(genbuf, "/usr/sbin/sendmail -f %s%s %s > /dev/null", - cuser.userid, str_mail_address, receiver); + snprintf(genbuf, sizeof(genbuf), + "/usr/sbin/sendmail -f %s%s %s > /dev/null", + cuser.userid, str_mail_address, receiver); fin = fopen(fpath, "r"); } fout = popen(genbuf, "w"); @@ -1514,7 +1521,7 @@ bsmtp(char *fpath, char *title, char *rcpt, int method) /* stamp the queue file */ strlcpy(buf, "out/", sizeof(buf)); for (;;) { - sprintf(buf + 4, "M.%ld.A", ++chrono); + snprintf(buf + 4, sizeof(buf) - 4, "M.%ld.A", ++chrono); if (!dashf(buf)) { Link(fpath, buf); break; @@ -1550,7 +1557,8 @@ doforward(char *direct, fileheader_t * fh, int mode) strlcpy(address, cuser.email, sizeof(address)); if (address[0]) { - sprintf(genbuf, "�T�w��H�� [%s] ��(Y/N/Q)�H[Y] ", address); + snprintf(genbuf, sizeof(genbuf), + "�T�w��H�� [%s] ��(Y/N/Q)�H[Y] ", address); getdata(b_lines - 1, 0, genbuf, fname, 3, LCECHO); if (fname[0] == 'q') { @@ -1567,7 +1575,8 @@ doforward(char *direct, fileheader_t * fh, int mode) if (strchr(fname, '.')) strlcpy(address, fname, sizeof(address)); else - sprintf(address, "%s.bbs@%s", fname, MYHOSTNAME); + snprintf(address, sizeof(address), + "%s.bbs@%s", fname, MYHOSTNAME); } else { outmsg("������H"); return 1; @@ -1577,7 +1586,7 @@ doforward(char *direct, fileheader_t * fh, int mode) if (invalidaddr(address)) return -2; - sprintf(fname, "����H�� %s, �еy��...", address); + snprintf(fname, sizeof(fname), "����H�� %s, �еy��...", address); outmsg(fname); move(b_lines - 1, 0); refresh(); @@ -1586,19 +1595,20 @@ doforward(char *direct, fileheader_t * fh, int mode) if (HAS_PERM(PERM_LOGUSER)) { char msg[200]; - sprintf(msg, "%s mailforward to %s at %s", - cuser.userid, address, Cdate(&now)); + snprintf(msg, sizeof(msg), "%s mailforward to %s at %s", + cuser.userid, address, Cdate(&now)); log_user(msg); } if (mode == 'Z') { - sprintf(fname, TAR_PATH " cfz /tmp/home.%s.tgz home/%c/%s; " - MUTT_PATH " -a /tmp/home.%s.tgz -s 'home.%s.tgz' '%s' </dev/null;" - "rm /tmp/home.%s.tgz", - cuser.userid, cuser.userid[0], cuser.userid, - cuser.userid, cuser.userid, address, cuser.userid); + snprintf(fname, sizeof(fname), + TAR_PATH " cfz /tmp/home.%s.tgz home/%c/%s; " + MUTT_PATH " -a /tmp/home.%s.tgz -s 'home.%s.tgz' '%s' </dev/null;" + "rm /tmp/home.%s.tgz", + cuser.userid, cuser.userid[0], cuser.userid, + cuser.userid, cuser.userid, address, cuser.userid); system(fname); return 0; - sprintf(fname, TAR_PATH " cfz - home/%c/%s | " + snprintf(fname, sizeof(fname), TAR_PATH " cfz - home/%c/%s | " "/usr/bin/uuencode %s.tgz > %s", cuser.userid[0], cuser.userid, cuser.userid, direct); system(fname); @@ -1606,15 +1616,17 @@ doforward(char *direct, fileheader_t * fh, int mode) } else if (mode == 'U') { char tmp_buf[128]; - sprintf(fname, "/tmp/bbs.uu%05d", currpid); - sprintf(tmp_buf, "/usr/bin/uuencode %s/%s uu.%05d > %s", - direct, fh->filename, currpid, fname); + snprintf(fname, sizeof(fname), "/tmp/bbs.uu%05d", currpid); + snprintf(tmp_buf, sizeof(tmp_buf), + "/usr/bin/uuencode %s/%s uu.%05d > %s", + direct, fh->filename, currpid, fname); system(tmp_buf); } else if (mode == 'F') { char tmp_buf[128]; - sprintf(fname, "/tmp/bbs.f%05d", currpid); - sprintf(tmp_buf, "cp %s/%s %s", direct, fh->filename, fname); + snprintf(fname, sizeof(fname), "/tmp/bbs.f%05d", currpid); + snprintf(tmp_buf, sizeof(tmp_buf), + "cp %s/%s %s", direct, fh->filename, fname); system(tmp_buf); } else return -1; @@ -1693,7 +1705,7 @@ mail_justify(userec_t muser) checksum = (checksum << 1) ^ ch; } - sprintf(title, "[PTT BBS]To %s(%d:%d) [User Justify]", + snprintf(title, sizeof(title), "[PTT BBS]To %s(%d:%d) [User Justify]", muser.userid, getuser(muser.userid) + MAGIC_KEY, checksum); if ( #ifndef USE_BSMTP diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 6b3e15f3..9a3eeb8a 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1,4 +1,4 @@ -/* $Id: mbbsd.c,v 1.43 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: mbbsd.c,v 1.44 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define SOCKET_QLEN 4 @@ -118,8 +118,8 @@ log_user(char *msg) { char filename[200]; - sprintf(filename, BBSHOME "/home/%c/%s/USERLOG", - cuser.userid[0], cuser.userid); + snprintf(filename, sizeof(filename), BBSHOME "/home/%c/%s/USERLOG", + cuser.userid[0], cuser.userid); log_file(filename, msg); } @@ -130,13 +130,15 @@ log_usies(char *mode, char *mesg) char genbuf[200]; if (!mesg) - sprintf(genbuf, cuser.userid[0] ? "%s %s %-12s Stay:%d (%s)" : - "%s %s %s Stay:%d (%s)", - Cdate(&now), mode, cuser.userid, - (int)(now - login_start_time) / 60, cuser.username); + snprintf(genbuf, sizeof(genbuf), + cuser.userid[0] ? "%s %s %-12s Stay:%d (%s)" : + "%s %s %s Stay:%d (%s)", + Cdate(&now), mode, cuser.userid, + (int)(now - login_start_time) / 60, cuser.username); else - sprintf(genbuf, cuser.userid[0] ? "%s %s %-12s %s" : "%s %s %s%s", - Cdate(&now), mode, cuser.userid, mesg); + snprintf(genbuf, sizeof(genbuf), + cuser.userid[0] ? "%s %s %-12s %s" : "%s %s %s%s", + Cdate(&now), mode, cuser.userid, mesg); log_file(FN_USIES, genbuf); /* �l�ܨϥΪ� */ @@ -252,10 +254,11 @@ talk_request(int sig) char buf[200]; time_t now = time(0); - sprintf(buf, "\033[33;41m��%s\033[34;47m [%s] %s \033[0m", - SHM->uinfo[currutmp->destuip].userid, my_ctime(&now), - (currutmp->sig == 2) ? "���n�����s���I(��Ctrl-U,l�d�ݼ��T�O��)" - : "�I�s�B�I�s�Ať��Ц^��"); + snprintf(buf, sizeof(buf), + "\033[33;41m��%s\033[34;47m [%s] %s \033[0m", + SHM->uinfo[currutmp->destuip].userid, my_ctime(&now), + (currutmp->sig == 2) ? "���n�����s���I(��Ctrl-U,l�d�ݼ��T�O��)" + : "�I�s�B�I�s�Ať��Ц^��"); move(0, 0); clrtoeol(); outs(buf); @@ -281,8 +284,8 @@ void show_call_in(int save, int which) { char buf[200]; - sprintf(buf, "\033[1;33;46m��%s\033[37;45m %s \033[m", - currutmp->msgs[which].userid, currutmp->msgs[which].last_call_in); + snprintf(buf, sizeof(buf), "\033[1;33;46m��%s\033[37;45m %s \033[m", + currutmp->msgs[which].userid, currutmp->msgs[which].last_call_in); move(b_lines, 0); clrtoeol(); refresh(); @@ -485,7 +488,7 @@ logattempt(char *uid, char type) int fd, len; char genbuf[200]; - sprintf(genbuf, "%c%-12s[%s] %s@%s\n", type, uid, + snprintf(genbuf, sizeof(genbuf), "%c%-12s[%s] %s@%s\n", type, uid, Cdate(&login_start_time), remoteusername, fromhost); len = strlen(genbuf); if ((fd = open(str_badlogin, O_WRONLY | O_CREAT | O_APPEND, 0644)) > 0) { @@ -493,7 +496,8 @@ logattempt(char *uid, char type) close(fd); } if (type == '-') { - sprintf(genbuf, "[%s] %s\n", Cdate(&login_start_time), fromhost); + snprintf(genbuf, sizeof(genbuf), + "[%s] %s\n", Cdate(&login_start_time), fromhost); len = strlen(genbuf); sethomefile(fname, uid, str_badlogin); if ((fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, 0644)) > 0) { @@ -733,7 +737,7 @@ setup_utmp(int mode) #ifndef FAST_LOGIN setuserfile(buf, "remoteuser"); - strlcpy(remotebuf, fromhost, SIZEOF(remotebuf)); + strlcpy(remotebuf, fromhost, sizeof(fromhost)); strcat(remotebuf, ctime(&now)); remotebuf[strlen(remotebuf) - 1] = 0; add_distinct(buf, remotebuf); @@ -794,7 +798,7 @@ user_login() char buf[80]; int nScreens; for (nScreens = 0; nScreens < 10; ++nScreens) { - sprintf(buf, "etc/Welcome_login.%d", nScreens); + snprintf(buf, sizeof(buf), "etc/Welcome_login.%d", nScreens); if (access(buf, 0) < 0) break; } @@ -803,7 +807,7 @@ user_login() //multi screen error ? more("etc/Welcome_login", NA); } else { - sprintf(buf, "etc/Welcome_login.%d", (int)login_start_time % nScreens); + snprintf(buf, sizeof(buf), "etc/Welcome_login.%d", (int)login_start_time % nScreens); more(buf, NA); } #else @@ -856,11 +860,14 @@ user_login() "�R����", "�ѤW", "�Ŧ�����G" }; i = login_start_time % 13; - sprintf(cuser.username, "����}�Ӫ�%s", nick[(int)i]); - sprintf(currutmp->username, cuser.username); - sprintf(cuser.realname, name[(int)i]); - sprintf(currutmp->realname, cuser.realname); - sprintf(cuser.address, addr[(int)i]); + snprintf(cuser.username, sizeof(cuser.username), + "����}�Ӫ�%s", nick[(int)i]); + strlcpy(currutmp->username, cuser.username, + sizeof(currutmp->username)); + strlcpy(cuser.realname, name[(int)i], sizeof(cuser.realname)); + strlcpy(currutmp->realname, cuser.realname, + sizeof(currutmp->realname)); + strlcpy(cuser.address, addr[(int)i], sizeof(cuser.address)); cuser.sex = i % 8; currutmp->pager = 2; pressanykey(); @@ -886,7 +893,7 @@ do_aloha(char *hello) setuserfile(genbuf, "aloha"); if ((fp = fopen(genbuf, "r"))) { - sprintf(genbuf, hello); + snprintf(genbuf, sizeof(genbuf), hello); while (fgets(userid, 80, fp)) { userinfo_t *uentp; int tuid; @@ -1114,7 +1121,7 @@ getremotename(struct sockaddr_in * from, char *rhost, char *rname) */ if ((cp = (char *)strchr(user, '\r'))) *cp = 0; - strlcpy(rname, user, SIZEOF(rname)); + strlcpy(rname, user, sizeof(user)); } } alarm(0); @@ -1231,7 +1238,7 @@ daemon_login(int argc, char *argv[], char *envp[]) else if (argc >= 2) listen_port = atoi(argv[1]); - sprintf(margs, "%s %d ", argv[0], listen_port); + snprintf(margs, sizeof(margs), "%s %d ", argv[0], listen_port); /* port binding */ xsin.sin_family = AF_INET; @@ -1248,7 +1255,7 @@ daemon_login(int argc, char *argv[], char *envp[]) setuid(BBSUID); chdir(BBSHOME); - sprintf(buf, "run/mbbsd.%d.pid", listen_port); + snprintf(buf, sizeof(buf), "run/mbbsd.%d.pid", listen_port); if ((fp = fopen(buf, "w"))) { fprintf(fp, "%d\n", getpid()); fclose(fp); diff --git a/mbbsd/menu.c b/mbbsd/menu.c index d51dd01e..08efc53d 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.15 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: menu.c,v 1.16 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* help & menu processring */ @@ -41,8 +41,9 @@ showtitle(char *title, char *mid) title++; #ifdef DEBUG else { - sprintf(numreg, "\033[41;5m current pid: %6d " TITLE_COLOR, - getpid()); + snprintf(numreg, sizeof(numreg), + "\033[41;5m current pid: %6d " TITLE_COLOR, + getpid()); mid = numreg; spc = 22; } @@ -51,9 +52,9 @@ showtitle(char *title, char *mid) mid = "\033[41;5m �l�t�ӫ��a�o " TITLE_COLOR; spc = 22; } else if (HAS_PERM(PERM_SYSOP) && (nreg = dashs(fn_register) / 163) > 10) { - sprintf(numreg, "\033[41;5m ��%03d/%03d���f�� " TITLE_COLOR, - nreg, - (int)dashs("register.new.tmp") / 163); + snprintf(numreg, sizeof(numreg), + "\033[41;5m ��%03d/%03d���f�� " TITLE_COLOR, + nreg, (int)dashs("register.new.tmp") / 163); mid = numreg; spc = 22; } @@ -141,13 +142,14 @@ movie(int i) outs(reset_color); } i = ptime->tm_wday << 1; - sprintf(mystatus, "\033[34;46m[%d/%d �P��%c%c %d:%02d]\033[1;33;45m%-14s" - "\033[30;47m �ثe�{�̦� \033[31m%d\033[30m�H, �ڬO\033[31m%-12s" - "\033[30m[����]\033[31m%s\033[0m", - ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1], - ptime->tm_hour, ptime->tm_min, currutmp->birth ? - "�ͤ�n�Ыȭ�" : SHM->today_is, - SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]); + snprintf(mystatus, sizeof(mystatus), + "\033[34;46m[%d/%d �P��%c%c %d:%02d]\033[1;33;45m%-14s" + "\033[30;47m �ثe�{�̦� \033[31m%d\033[30m�H, �ڬO\033[31m%-12s" + "\033[30m[����]\033[31m%s\033[0m", + ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1], + ptime->tm_hour, ptime->tm_min, currutmp->birth ? + "�ͤ�n�Ыȭ�" : SHM->today_is, + SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]); outmsg(mystatus); refresh(); } @@ -165,7 +167,7 @@ show_menu(commands_t * p) move(menu_row, 0); while ((s = p[n].desc)) { if (HAS_PERM(p[n].level)) { - sprintf(buf, s + 2, state[cuser.proverb % 4]); + snprintf(buf, sizeof(buf), s + 2, state[cuser.proverb % 4]); prints("%*s (\033[1;36m%c\033[0m)%s\n", menu_column, "", s[1], buf); } diff --git a/mbbsd/more.c b/mbbsd/more.c index 33c6e1b3..2acf144d 100644 --- a/mbbsd/more.c +++ b/mbbsd/more.c @@ -1,4 +1,4 @@ -/* $Id: more.c,v 1.17 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: more.c,v 1.18 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define MORE_BUFSIZE 4096 #define MORE_WINSIZE 4096 @@ -246,12 +246,14 @@ more(char *fpath, int promptend) strncpy(SearchStr, pos, strlen(search_str)); SearchStr[strlen(search_str)] = 0; searching = 0; - sprintf(msg, "%.*s\033[7m%s\033[m", pos - buf, buf, - SearchStr); + snprintf(msg, sizeof(msg), + "%.*s\033[7m%s\033[m", pos - buf, buf, + SearchStr); while ((pos = fptr(pos1 = pos + strlen(search_str), search_str))) { - sprintf(buf1, "%.*s\033[7m%s\033[m", pos - pos1, - pos1, SearchStr); + snprintf(buf1, sizeof(buf1), + "%.*s\033[7m%s\033[m", pos - pos1, + pos1, SearchStr); strcat(msg, buf1); } strcat(msg, pos1); @@ -497,7 +499,8 @@ more(char *fpath, int promptend) char tmpbuf[128]; setuserfile(tmpbuf, ask_tmpbuf(b_lines - 1)); - sprintf(buf, "cp -f %s %s", fpath, tmpbuf); + snprintf(buf, sizeof(buf), + "cp -f %s %s", fpath, tmpbuf); system(buf); } if (pageno) diff --git a/mbbsd/name.c b/mbbsd/name.c index 72aba76c..cbd872d9 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -1,4 +1,4 @@ -/* $Id: name.c,v 1.13 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: name.c,v 1.14 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static word_t *current = NULL; @@ -37,7 +37,7 @@ UserSubArray(char cwbuf[][IDLEN + 1], char cwlist[][IDLEN + 1], for (n = 0; n < cwnum; n++) { ch = cwlist[n][pos]; if (ch == key || ch == key2) - strlcpy(cwbuf[num++], cwlist[n], SIZEOF(cwbuf[num])); + strlcpy(cwbuf[num++], cwlist[n], sizeof(cwbuf[num])); } return num; } diff --git a/mbbsd/osdep.c b/mbbsd/osdep.c index f1b65242..6357a829 100644 --- a/mbbsd/osdep.c +++ b/mbbsd/osdep.c @@ -1,4 +1,4 @@ -/* $Id: osdep.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: osdep.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #if __FreeBSD__ @@ -57,7 +57,7 @@ cpuload(char *str) } if (str) { if (l[0] != -1) - sprintf(str, " %.2f %.2f %.2f", l[0], l[1], l[2]); + snprintf(str, sizeof(str), " %.2f %.2f %.2f", l[0], l[1], l[2]); else strcpy(str, " (unknown) "); } diff --git a/mbbsd/page.c b/mbbsd/page.c index 988b222b..e32b73f2 100644 --- a/mbbsd/page.c +++ b/mbbsd/page.c @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: page.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define hpressanykey(a) {move(22, 0); prints(a); pressanykey();} @@ -8,7 +8,7 @@ filt_railway(char *fpath) char buf[256], tmppath[32]; FILE *fp = fopen(fpath, "w"), *tp; - sprintf(tmppath, "%s.railway", fpath); + snprintf(tmppath, sizeof(tmppath), "%s.railway", fpath); if (!fp || !(tp = fopen(tmppath, "r"))) return; @@ -104,7 +104,7 @@ main_railway() strlcpy(mhdr.owner, "Ptt�j�M��", sizeof(mhdr.owner)); strncpy(mhdr.title, "�����ɨ�j�M���G", TTLEN); - sprintf(command, "echo \"from-station=%s&to-station=%s" + snprintf(command, sizeof(command), "echo \"from-station=%s&to-station=%s" "&from-time=%02d00&to-time=%02d00&tt=%s&type=%s\" | " "lynx -dump -post_data " "\"http://www.railway.gov.tw/cgi-bin/timetk.cgi\" > %s.railway", diff --git a/mbbsd/read.c b/mbbsd/read.c index 5a915d3b..f979e2dd 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.10 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: read.c,v 1.11 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define MAXPATHLEN 256 @@ -76,7 +76,7 @@ Tagger(time_t chrono, int recno, int mode) void EnumTagName(char *fname, int locus) { - sprintf(fname, "M.%d.A", (int)TagList[locus].chrono); + snprintf(fname, sizeof(fname), "M.%d.A", (int)TagList[locus].chrono); } void @@ -96,7 +96,7 @@ AskTag(char *msg) int num; num = TagNum; - sprintf(buf, "�� %s A)�峹 T)�аO Q)uit?", msg); + snprintf(buf, sizeof(buf), "�� %s A)�峹 T)�аO Q)uit?", msg); switch (rget(b_lines - 1, buf)) { case 'q': num = -1; @@ -346,8 +346,9 @@ thread(keeploc_t * locmem, int stype) else if (*currauthor) strlcpy(a_ans, currauthor, sizeof(a_ans)); } - sprintf(s_pmt, "%s�j�M%s [%s] ", (stype & RS_FORWARD) ? "����" : "���e", - (stype & RS_TITLE) ? "���D" : "�@��", query); + snprintf(s_pmt, sizeof(s_pmt), + "%s�j�M%s [%s] ", (stype & RS_FORWARD) ? "����" : "���e", + (stype & RS_TITLE) ? "���D" : "�@��", query); getdata(b_lines - 1, 0, s_pmt, ans, sizeof(ans), DOECHO); if (*ans) strcpy(query, ans); @@ -471,8 +472,8 @@ select_read(keeploc_t * locmem, int sr_mode) char newdata[35]; query = (sr_mode == RS_RELATED) ? t_ans : a_ans; - sprintf(buff, "�j�M%s [%s] ", - (sr_mode == RS_RELATED) ? "���D" : "�@��", query); + snprintf(buff, sizeof(buff), "�j�M%s [%s] ", + (sr_mode == RS_RELATED) ? "���D" : "�@��", query); getdata(b_lines, 0, buff, newdata, sizeof(newdata), DOECHO); if (newdata[0]) strcpy(query, newdata); @@ -481,7 +482,7 @@ select_read(keeploc_t * locmem, int sr_mode) } if ((fd = open(currdirect, O_RDONLY, 0)) != -1) { - sprintf(genbuf, "SR.%s", cuser.userid); + snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser.userid); if (currstat == RMAIL) sethomefile(fpath, cuser.userid, genbuf); else diff --git a/mbbsd/record.c b/mbbsd/record.c index d8ce7aa2..bd0c5316 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -1,4 +1,4 @@ -/* $Id: record.c,v 1.9 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: record.c,v 1.10 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #undef HAVE_MMAP @@ -136,9 +136,9 @@ typedef struct nol_t { static void nolfilename(nol_t * n, char *fpath) { - sprintf(n->newfn, "%s.new", fpath); - sprintf(n->oldfn, "%s.old", fpath); - sprintf(n->lockfn, "%s.lock", fpath); + snprintf(n->newfn, sizeof(n->newfn), "%s.new", fpath); + snprintf(n->oldfn, sizeof(n->oldfn), "%s.old", fpath); + snprintf(n->lockfn, sizeof(n->lockfn), "%s.lock", fpath); } int @@ -444,7 +444,8 @@ stampfile(char *fpath, fileheader_t * fh) memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); + snprintf(fh->date, sizeof(fh->date), + "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); return 0; } @@ -466,7 +467,8 @@ stampdir(char *fpath, fileheader_t * fh) memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); + snprintf(fh->date, sizeof(fh->date), + "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); } void @@ -487,7 +489,8 @@ stamplink(char *fpath, fileheader_t * fh) memset(fh, 0, sizeof(fileheader_t)); strlcpy(fh->filename, ip, sizeof(fh->filename)); ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); + snprintf(fh->date, sizeof(fh->date), + "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); } int diff --git a/mbbsd/register.c b/mbbsd/register.c index 26204ce8..5ef02f4a 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -1,4 +1,4 @@ -/* $Id: register.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: register.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #define _XOPEN_SOURCE #include "bbs.h" @@ -104,18 +104,19 @@ check_and_expire_account(int uid, userec_t * urec) char genbuf[200], genbuf2[200]; int val; if ((val = compute_user_value(urec, now)) < 0) { - sprintf(genbuf, "#%d %-12s %15.15s %d %d %d", + snprintf(genbuf, sizeof(genbuf), "#%d %-12s %15.15s %d %d %d", uid, urec->userid, ctime(&(urec->lastlogin)) + 4, urec->numlogins, urec->numposts, val); if (val > -1 * 60 * 24 * 365) { memset(&zerorec, 0, sizeof(zerorec)); log_usies("CLEAN", genbuf); - sprintf(genbuf, "home/%c/%s", urec->userid[0], + snprintf(genbuf, sizeof(genbuf), "home/%c/%s", urec->userid[0], urec->userid); - sprintf(genbuf2, "tmp/%s", urec->userid); + snprintf(genbuf2, sizeof(genbuf2), "tmp/%s", urec->userid); if (dashd(genbuf) && Rename(genbuf, genbuf2)) { - sprintf(genbuf, "/bin/rm -fr home/%c/%s >/dev/null 2>&1", - urec->userid[0], urec->userid); + snprintf(genbuf, sizeof(genbuf), + "/bin/rm -fr home/%c/%s >/dev/null 2>&1", + urec->userid[0], urec->userid); system(genbuf); } passwd_update(uid, &zerorec); @@ -174,7 +175,7 @@ getnewuserid() safe_sleep(2); exit(1); } - sprintf(genbuf, "uid %d", i); + snprintf(genbuf, sizeof(genbuf), "uid %d", i); log_usies("APPLY", genbuf); strlcpy(zerorec.userid, str_new, sizeof(zerorec.userid)); @@ -214,7 +215,8 @@ new_register() if (id == 999999) outs("���N���w�g���H�ϥ� �O��������"); else { - sprintf(passbuf, "���N���w�g���H�ϥ� �٦�%d�Ѥ~�L�� \n", id / (60 * 24)); + snprintf(passbuf, sizeof(passbuf), + "���N���w�g���H�ϥ� �٦�%d�Ѥ~�L�� \n", id / (60 * 24)); outs(passbuf); } } else diff --git a/mbbsd/screen.c b/mbbsd/screen.c index 59032a85..a7f4526c 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.7 2002/07/21 20:39:34 kcwu Exp $ */ +/* $Id: screen.c,v 1.8 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #ifdef SUPPORT_GB @@ -336,7 +336,7 @@ parsecolor(char *buf) } val = (char *)strtok(NULL, ";"); } - strlcpy(buf, data, SIZEOF(buf)); + strlcpy(buf, data, sizeof(data)); } #define NORMAL (00) @@ -483,7 +483,7 @@ prints(char *fmt,...) char buff[1024]; va_start(args, fmt); - vsprintf(buff, fmt, args); + vsnprintf(buff, sizeof(buff), fmt, args); va_end(args); outs(buff); } diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index d3297eda..76a3a032 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -1,4 +1,4 @@ -/* $Id: stuff.c,v 1.8 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: stuff.c,v 1.9 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* ----------------------------------------------------- */ @@ -337,19 +337,19 @@ gettime(int line, time_t dt) struct tm *ptime = localtime(&dt), endtime; memcpy(&endtime, ptime, sizeof(struct tm)); - sprintf(yn, "%4d", ptime->tm_year + 1900); + snprintf(yn, sizeof(yn), "%4d", ptime->tm_year + 1900); do { getdata_buf(line, 0, "�褸�~:", yn, 5, LCECHO); } while ((endtime.tm_year = atoi(yn) - 1900) < 0 || endtime.tm_year > 200); - sprintf(yn, "%d", ptime->tm_mon + 1); + snprintf(yn, sizeof(yn), "%d", ptime->tm_mon + 1); do { getdata_buf(line, 13, "��:", yn, 3, LCECHO); } while ((endtime.tm_mon = atoi(yn) - 1) < 0 || endtime.tm_mon > 11); - sprintf(yn, "%d", ptime->tm_mday); + snprintf(yn, sizeof(yn), "%d", ptime->tm_mday); do { getdata_buf(line, 22, "��:", yn, 3, LCECHO); } while ((endtime.tm_mday = atoi(yn)) < 1 || endtime.tm_mday > 31); - sprintf(yn, "%d", ptime->tm_hour); + snprintf(yn, sizeof(yn), "%d", ptime->tm_hour); do { getdata_buf(line, 31, "��(0-23):", yn, 3, LCECHO); } while ((endtime.tm_hour = atoi(yn)) < 0 || endtime.tm_hour > 23); @@ -434,7 +434,7 @@ vmsg(const char *fmt,...) int ch; va_start(ap, fmt); - vsprintf(msg, fmt, ap); + vsnprintf(msg, sizeof(msg), fmt, ap); va_end(ap); move(b_lines, 0); diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index 965ce93b..0a527f22 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -1,4 +1,4 @@ -/* $Id: syspost.c,v 1.14 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: syspost.c,v 1.15 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" void @@ -36,8 +36,9 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) cuser.userid, reason); fclose(fp); - sprintf(fhdr.title, "[���w���i] ����%s�ק�%s�v�����i", - cuser.userid, userid); + snprintf(fhdr.title, sizeof(fhdr.title), + "[���w���i] ����%s�ק�%s�v�����i", + cuser.userid, userid); strlcpy(fhdr.owner, "[�t�Φw����]", sizeof(fhdr.owner)); append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr)); } @@ -60,7 +61,8 @@ post_violatelaw(char *crime, char *police, char *reason, char *result) "�]\033[1;35m%s\033[m�欰�A\n�H�ϥ������W�A�B�H\033[1;35m%s\033[m�A�S�����i", crime, ctime(&now), police, crime, reason, result); fclose(fp); - sprintf(fhdr.title, "[���i] %-20s �H�k�P�M���i", crime); + snprintf(fhdr.title, sizeof(fhdr.title), + "[���i] %-20s �H�k�P�M���i", crime); strlcpy(fhdr.owner, "[Ptt�k�|]", sizeof(fhdr.owner)); append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr)); @@ -75,7 +77,8 @@ post_violatelaw(char *crime, char *police, char *reason, char *result) "�]\033[1;35m%s\033[m�欰�A\n�H�ϥ������W�A�B�H\033[1;35m%s\033[m�A�S�����i", crime, ctime(&now), police, crime, reason, result); fclose(fp); - sprintf(fhdr.title, "[���i] %-20s �H�k�P�M���i", crime); + snprintf(fhdr.title, sizeof(fhdr.title), + "[���i] %-20s �H�k�P�M���i", crime); strlcpy(fhdr.owner, "[Ptt�k�|]", sizeof(fhdr.owner)); append_record("boards/V/ViolateLaw/.DIR", &fhdr, sizeof(fhdr)); @@ -86,9 +89,10 @@ void post_newboard(char *bgroup, char *bname, char *bms) { char genbuf[256], title[128]; - sprintf(title, "[�s�O����] %s", bname); - sprintf(genbuf, "%s �}�F�@�ӷs�O %s : %s\n\n�s���O�D�� %s\n\n����*^_^*\n", - cuser.userid, bname, bgroup, bms); + snprintf(title, sizeof(title), "[�s�O����] %s", bname); + snprintf(genbuf, sizeof(genbuf), + "%s �}�F�@�ӷs�O %s : %s\n\n�s���O�D�� %s\n\n����*^_^*\n", + cuser.userid, bname, bgroup, bms); post_msg("Record", title, genbuf, "[�t��]"); } @@ -113,8 +117,8 @@ give_money_post(char *userid, int money) cuser.userid, userid, money); fclose(fp); - sprintf(fhdr.title, "[���w���i] ����%s�ϥά��]�����i", - cuser.userid); + snprintf(fhdr.title, sizeof(fhdr.title), "[���w���i] ����%s�ϥά��]�����i", + cuser.userid); strlcpy(fhdr.owner, "[�t�Φw����]", sizeof(fhdr.owner)); append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr)); } diff --git a/mbbsd/talk.c b/mbbsd/talk.c index c78eb24e..56b2b88b 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.80 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: talk.c,v 1.81 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" #define QCAST int (*)(const void *, const void *) @@ -98,25 +98,27 @@ modestring(userinfo_t * uentp, int simple) !((fri_stat & HFM) && (fri_stat & HRM)))) return notonline; else if (mode == EDITING) { - sprintf(modestr, "E:%s", + snprintf(modestr, sizeof(modestr), "E:%s", ModeTypeTable[uentp->destuid < EDITING ? uentp->destuid : EDITING]); word = modestr; } else if (!mode && *uentp->chatid == 1) { if (!simple) - sprintf(modestr, "�^�� %s", getuserid(uentp->destuid)); + snprintf(modestr, sizeof(modestr), + "�^�� %s", getuserid(uentp->destuid)); else - sprintf(modestr, "�^���I�s"); + snprintf(modestr, sizeof(modestr), "�^���I�s"); } else if (!mode && *uentp->chatid == 2) if (uentp->msgcount < 10) { char *cnum[10] = {"", "�@", "��", "�T", "�|", "��", "��", "�C", "�K", "�E"}; - sprintf(modestr, "��%s�����y", cnum[uentp->msgcount]); + snprintf(modestr, sizeof(modestr), + "��%s�����y", cnum[uentp->msgcount]); } else - sprintf(modestr, "����F @_@"); + snprintf(modestr, sizeof(modestr), "����F @_@"); else if (!mode && *uentp->chatid == 3) - sprintf(modestr, "���y�dzƤ�"); + snprintf(modestr, sizeof(modestr), "���y�dzƤ�"); else if (!mode) return (uentp->destuid == 6) ? uentp->chatid : IdleTypeTable[(0 <= uentp->destuid && uentp->destuid < 6) ? @@ -124,27 +126,30 @@ modestring(userinfo_t * uentp, int simple) else if (simple) return word; else if (uentp->in_chat && mode == CHATING) - sprintf(modestr, "%s (%s)", word, uentp->chatid); + snprintf(modestr, sizeof(modestr), "%s (%s)", word, uentp->chatid); else if (mode == TALK) { if (!isvisible_uid(uentp->destuid)) /* Leeym ���(����)���� */ - sprintf(modestr, "%s", "��� �Ů�"); /* Leeym - * �j�a�ۤv�o���a�I */ + snprintf(modestr, sizeof(modestr), "%s", "��� �Ů�"); + /* Leeym * �j�a�ۤv�o���a�I */ else - sprintf(modestr, "%s %s", word, getuserid(uentp->destuid)); + snprintf(modestr, sizeof(modestr), + "%s %s", word, getuserid(uentp->destuid)); } else if (mode == M_FIVE) { if (!isvisible_uid(uentp->destuid)) - sprintf(modestr, "%s", "���l�� �Ů�"); + snprintf(modestr, sizeof(modestr), "%s", "���l�� �Ů�"); else - sprintf(modestr, "%s %s", word, getuserid(uentp->destuid)); + snprintf(modestr, sizeof(modestr), "%s %s", word, getuserid(uentp->destuid)); } else if (mode == CHC) { if (isvisible_uid(uentp->destuid)) - sprintf(modestr, "%s", "�U�H��"); + snprintf(modestr, sizeof(modestr), "%s", "�U�H��"); else - sprintf(modestr, "�U�H�� %s", getuserid(uentp->destuid)); + snprintf(modestr, sizeof(modestr), + "�U�H�� %s", getuserid(uentp->destuid)); } else if (mode != PAGE && mode != TQUERY) return word; else - sprintf(modestr, "%s %s", word, getuserid(uentp->destuid)); + snprintf(modestr, sizeof(modestr), + "%s %s", word, getuserid(uentp->destuid)); return (modestr); } @@ -301,7 +306,8 @@ my_kick(userinfo_t * uentp) getdata(1, 0, msg_sure_ny, genbuf, 4, LCECHO); clrtoeol(); if (genbuf[0] == 'y') { - sprintf(genbuf, "%s (%s)", uentp->userid, uentp->username); + snprintf(genbuf, sizeof(genbuf), + "%s (%s)", uentp->userid, uentp->username); log_usies("KICK ", genbuf); if ((uentp->pid <= 0 || kill(uentp->pid, SIGHUP) == -1) && (errno == ESRCH)) purge_utmp(uentp); @@ -321,13 +327,14 @@ chicken_query(char *userid) time_diff(&(xuser.mychicken)); if (!isdeadth(&(xuser.mychicken))) { show_chicken_data(&(xuser.mychicken), NULL); - sprintf(buf, "\n\n�H�W�O %s ���d�����..", userid); + snprintf(buf, sizeof(buf), + "\n\n�H�W�O %s ���d�����..", userid); outs(buf); } } else { move(1, 0); clrtobot(); - sprintf(buf, "\n\n%s �èS���i�d��..", userid); + snprintf(buf, sizeof(buf), "\n\n%s �èS���i�d��..", userid); outs(buf); } pressanykey(); @@ -525,7 +532,7 @@ my_write2(void) move(0, 0); prints("\033[m"); clrtoeol(); - sprintf(genbuf, "���� %s:", tw->userid); + snprintf(genbuf, sizeof(genbuf), "���� %s:", tw->userid); if (!oldgetdata(0, 0, genbuf, msg, 80 - strlen(tw->userid) - 6, DOECHO)) break; @@ -604,7 +611,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin) strip_ansi(msg, msg, 0); if (uin && *uin->userid && (flag == 0 || flag == 4)) { - sprintf(buf, "�ᵹ %s : %s [Y/n]?", uin->userid, msg); + snprintf(buf, sizeof(buf), "�ᵹ %s : %s [Y/n]?", uin->userid, msg); getdata(0, 0, buf, genbuf, 3, LCECHO); if (genbuf[0] == 'n') { outmsg("\033[1;33;42m��F! ��A�@��...\033[m"); @@ -976,7 +983,7 @@ do_talk(int fd) setutmpmode(TALK); ch = 58 - strlen(save_page_requestor); - sprintf(genbuf, "%s�i%s", cuser.userid, cuser.username); + snprintf(genbuf, sizeof(genbuf), "%s�i%s", cuser.userid, cuser.username); i = ch - strlen(genbuf); if (i >= 0) i = (i >> 1) + 1; @@ -987,8 +994,9 @@ do_talk(int fd) memset(data, ' ', i); data[i] = '\0'; - sprintf(mid_line, "\033[1;46;37m �ͤѻ��a \033[45m%s%s�j" - " �P %s%s\033[0m", data, genbuf, save_page_requestor, data); + snprintf(mid_line, sizeof(mid_line), + "\033[1;46;37m �ͤѻ��a \033[45m%s%s�j" + " �P %s%s\033[0m", data, genbuf, save_page_requestor, data); memset(&mywin, 0, sizeof(mywin)); memset(&itswin, 0, sizeof(itswin)); @@ -1076,8 +1084,9 @@ do_talk(int fd) stampfile(genbuf, &mymail); mymail.filemode = FILE_READ | FILE_HOLD; strlcpy(mymail.owner, "[��.��.��]", sizeof(mymail.owner)); - sprintf(mymail.title, "��ܰO�� \033[1;36m(%s)\033[m", - getuserid(currutmp->destuid)); + snprintf(mymail.title, sizeof(mymail.title), + "��ܰO�� \033[1;36m(%s)\033[m", + getuserid(currutmp->destuid)); sethomedir(title, cuser.userid); Rename(fpath, genbuf); append_record(title, &mymail, sizeof(mymail)); @@ -1269,8 +1278,8 @@ my_talk(userinfo_t * uin, int fri_stat) read(msgsock, &c, sizeof c); if (c == 'y') { - sprintf(save_page_requestor, "%s (%s)", - uin->userid, uin->username); + snprintf(save_page_requestor, sizeof(save_page_requestor), + "%s (%s)", uin->userid, uin->username); /* gomo */ switch (uin->sig) { case SIG_DARK: @@ -1399,7 +1408,7 @@ friend_descript(char *uident) setuserfile(fpath, friend_file[0]); if ((fp = fopen(fpath, "r"))) { - sprintf(name, "%s ", uident); + snprintf(name, sizeof(name), "%s ", uident); len = strlen(name); desc = genbuf + 13; @@ -1439,8 +1448,9 @@ descript(int show_mode, userinfo_t * uentp, time_t diff) #endif : "*"); case 2: - sprintf(description, "%3d/%3d/%3d", uentp->five_win, - uentp->five_lose, uentp->five_tie); + snprintf(description, sizeof(description), + "%3d/%3d/%3d", uentp->five_win, + uentp->five_lose, uentp->five_tie); description[20] = 0; return description; default: @@ -1671,11 +1681,11 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way, if (idletime > 86400) strlcpy(idlestr, " -----", sizeof(idlestr)); else if (idletime >= 3600) - sprintf(idlestr, "%3dh%02d", - idletime / 3600, (idletime / 60) % 60); + snprintf(idlestr, sizeof(idlestr), "%3dh%02d", + idletime / 3600, (idletime / 60) % 60); else if (idletime > 0) - sprintf(idlestr, "%3d'%02d", - idletime / 60, idletime % 60); + snprintf(idlestr, sizeof(idlestr), "%3d'%02d", + idletime / 60, idletime % 60); else strlcpy(idlestr, " ", sizeof(idlestr)); #endif @@ -1743,7 +1753,7 @@ call_in(userinfo_t * uentp, int fri_stat) { if (iswritable_stat(uentp, fri_stat)) { char genbuf[60]; - sprintf(genbuf, "Call-In %s �G", uentp->userid); + snprintf(genbuf, sizeof(genbuf), "Call-In %s �G", uentp->userid); my_write(uentp->pid, genbuf, uentp->userid, 0, NULL); return 1; } @@ -1857,7 +1867,8 @@ userlist(void) case 'D': if (HAS_PERM(PERM_SYSOP)) { char buf[100]; - sprintf(buf, "�N�� [%s]�G", currutmp->userid); + snprintf(buf, sizeof(buf), + "�N�� [%s]�G", currutmp->userid); if (!getdata(1, 0, buf, currutmp->userid, sizeof(buf), DOECHO)) strlcpy(currutmp->userid, cuser.userid, sizeof(currutmp->userid)); @@ -1869,7 +1880,7 @@ userlist(void) if (HAS_PERM(PERM_SYSOP)) { char buf[100]; - sprintf(buf, "�G�m [%s]�G", currutmp->from); + snprintf(buf, sizeof(buf), "�G�m [%s]�G", currutmp->from); if (!getdata(1, 0, buf, currutmp->from, sizeof(currutmp->from), DOECHO)) strncpy(currutmp->from, fromhost, 23); @@ -2171,7 +2182,8 @@ userlist(void) if (HAS_PERM(PERM_LOGINOK) && strcmp(uentp->userid, cuser.userid) != 0) { move(b_lines - 2, 0); - sprintf(genbuf, "�n�� %s �h�ֿ��O? ", uentp->userid); + snprintf(genbuf, sizeof(genbuf), + "�n�� %s �h�ֿ��O? ", uentp->userid); outs(genbuf); if (getdata(b_lines - 1, 0, "[�Ȧ���b]: ", genbuf, 7, LCECHO)) { @@ -2184,12 +2196,14 @@ userlist(void) outs("\033[41m �{������~~\033[m"); else { deumoney(uentp->uid, ch - give_tax(ch)); - sprintf(genbuf, "\033[44m ��..�ٳѤU %d ��.." - "\033[m", demoney(-ch)); + snprintf(genbuf, sizeof(genbuf), + "\033[44m ��..�ٳѤU %d ��.." + "\033[m", demoney(-ch)); outs(genbuf); - sprintf(genbuf, "%s\t��%s\t%d\t%s", cuser.userid, - uentp->userid, ch, - ctime(&currutmp->lastact)); + snprintf(genbuf, sizeof(genbuf), + "%s\t��%s\t%d\t%s", cuser.userid, + uentp->userid, ch, + ctime(&currutmp->lastact)); log_file(FN_MONEY, genbuf); mail_redenvelop(cuser.userid, uentp->userid, ch - give_tax(ch), 'Y'); @@ -2326,8 +2340,9 @@ t_idle(void) do { move(b_lines - 2, 0); clrtoeol(); - sprintf(buf, "(��w�ù�)�o�b��]: %s", (currutmp->destuid != 6) ? - IdleTypeTable[currutmp->destuid] : currutmp->chatid); + snprintf(buf, sizeof(buf), + "(��w�ù�)�o�b��]: %s", (currutmp->destuid != 6) ? + IdleTypeTable[currutmp->destuid] : currutmp->chatid); outs(buf); refresh(); getdata(b_lines - 1, 0, MSG_PASSWD, passbuf, sizeof(passbuf), NOECHO); @@ -2427,7 +2442,8 @@ talkreply(void) talkrequest = NA; uip = &SHM->uinfo[currutmp->destuip]; - sprintf(page_requestor, "%s (%s)", uip->userid, uip->username); + snprintf(page_requestor, sizeof(page_requestor), + "%s (%s)", uip->userid, uip->username); currutmp->destuid = uip->uid; currstat = XMODE; /* �קK�X�{�ʵe */ @@ -2456,12 +2472,14 @@ talkreply(void) showplans(uip->userid); show_call_in(0, 0); - sprintf(genbuf, "�A�Q�� %s %s�ڡH�п��(Y/N/A/B/C/D/E/F/1/2)[N] ", - page_requestor, sig_des[sig]); + snprintf(genbuf, sizeof(genbuf), + "�A�Q�� %s %s�ڡH�п��(Y/N/A/B/C/D/E/F/1/2)[N] ", + page_requestor, sig_des[sig]); getdata(0, 0, genbuf, buf, sizeof(buf), LCECHO); if (uip->mode != PAGE) { - sprintf(genbuf, "%s�w����I�s�A��Enter�~��...", page_requestor); + snprintf(genbuf, sizeof(genbuf), + "%s�w����I�s�A��Enter�~��...", page_requestor); getdata(0, 0, genbuf, buf, sizeof(buf), LCECHO); return; } diff --git a/mbbsd/term.c b/mbbsd/term.c index ced6b1c4..9694add2 100644 --- a/mbbsd/term.c +++ b/mbbsd/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: term.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" int tgetent(const char *bp, char *name); @@ -91,7 +91,7 @@ do_move(int destcol, int destline) { char buf[16], *p; - sprintf(buf, "\33[%d;%dH", destline + 1, destcol + 1); + snprintf(buf, sizeof(buf), "\33[%d;%dH", destline + 1, destcol + 1); for (p = buf; *p; p++) ochar(*p); } @@ -115,7 +115,7 @@ change_scroll_range(int top, int bottom) { char buf[16], *p; - sprintf(buf, "\33[%d;%dr", top + 1, bottom + 1); + snprintf(buf, sizeof(buf), "\33[%d;%dr", top + 1, bottom + 1); for (p = buf; *p; p++) ochar(*p); } diff --git a/mbbsd/user.c b/mbbsd/user.c index b830fe5c..d6dd4b20 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1,4 +1,4 @@ -/* $Id: user.c,v 1.32 2002/07/21 10:11:13 in2 Exp $ */ +/* $Id: user.c,v 1.33 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" static char *sex[8] = { @@ -122,7 +122,7 @@ mail_violatelaw(char *crime, char *police, char *reason, char *result) char genbuf[200]; fileheader_t fhdr; FILE *fp; - sprintf(genbuf, "home/%c/%s", crime[0], crime); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s", crime[0], crime); stampfile(genbuf, &fhdr); if (!(fp = fopen(genbuf, "w"))) return; @@ -134,9 +134,9 @@ mail_violatelaw(char *crime, char *police, char *reason, char *result) "\n�Ш� PttLaw �d�߬����k�W��T�A�è� Play-Pay-ViolateLaw ú��@��", ctime(&now), police, crime, reason, result); fclose(fp); - sprintf(fhdr.title, "[���i] �H�k�P�M���i"); + snprintf(fhdr.title, sizeof(fhdr.title), "[���i] �H�k�P�M���i"); strlcpy(fhdr.owner, "[Ptt�k�|]", sizeof(fhdr.owner)); - sprintf(genbuf, "home/%c/%s/.DIR", crime[0], crime); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s/.DIR", crime[0], crime); append_record(genbuf, &fhdr, sizeof(fhdr)); } @@ -153,13 +153,13 @@ violate_law(userec_t * u, int unum) getdata(5, 0, "(0)����", ans, sizeof(ans), DOECHO); switch (ans[0]) { case '1': - sprintf(reason, "%s", "Cross-post"); + snprintf(reason, sizeof(reason), "%s", "Cross-post"); break; case '2': - sprintf(reason, "%s", "�õo�s�i�H"); + snprintf(reason, sizeof(reason), "%s", "�õo�s�i�H"); break; case '3': - sprintf(reason, "%s", "�õo�s��H"); + snprintf(reason, sizeof(reason), "%s", "�õo�s��H"); break; case '4': while (!getdata(7, 0, "�п�J�Q���|�z�ѥH�ܭt�d�G", reason, 50, DOECHO)); @@ -177,8 +177,8 @@ violate_law(userec_t * u, int unum) return; if (ans[0] == '9') { char src[STRLEN], dst[STRLEN]; - sprintf(src, "home/%c/%s", u->userid[0], u->userid); - sprintf(dst, "tmp/%s", u->userid); + snprintf(src, sizeof(src), "home/%c/%s", u->userid[0], u->userid); + snprintf(dst, sizeof(dst), "tmp/%s", u->userid); Rename(src, dst); log_usies("KILL", u->userid); post_violatelaw(u->userid, cuser.userid, reason, "�尣 ID"); @@ -247,7 +247,7 @@ uinfo_query(userec_t * u, int real, int unum) getdata_buf(i++, 0, "�~���a�}�G", x.address, sizeof(x.address), DOECHO); } - sprintf(buf, "%010d", x.mobile); + snprintf(buf, sizeof(buf), "%010d", x.mobile); getdata_buf(i++, 0, "������X�G", buf, 11, LCECHO); x.mobile = atoi(buf); getdata_str(i++, 0, "�q�l�H�c[�ܰʭn���s�{��]�G", buf, 50, DOECHO, @@ -256,7 +256,7 @@ uinfo_query(userec_t * u, int real, int unum) strlcpy(x.email, buf, sizeof(x.email)); mail_changed = 1 - real; } - sprintf(genbuf, "%i", (u->sex + 1) % 8); + snprintf(genbuf, sizeof(genbuf), "%i", (u->sex + 1) % 8); getdata_str(i++, 0, "�ʧO (1)���� (2)�j�� (3)���} (4)���� (5)���� " "(6)���� (7)�Ӫ� (8)�q���G", buf, 3, DOECHO, genbuf); @@ -268,8 +268,8 @@ uinfo_query(userec_t * u, int real, int unum) while (1) { int len; - sprintf(genbuf, "%02i/%02i/%02i", - u->month, u->day, u->year % 100); + snprintf(genbuf, sizeof(genbuf), "%02i/%02i/%02i", + u->month, u->day, u->year % 100); len = getdata_str(i, 0, "�ͤ� ���/���/�褸�G", buf, 9, DOECHO, genbuf); if (len && len != 8) @@ -293,7 +293,7 @@ uinfo_query(userec_t * u, int real, int unum) if (real) { unsigned long int l; if (HAS_PERM(PERM_BBSADM)) { - sprintf(genbuf, "%d", x.money); + snprintf(genbuf, sizeof(genbuf), "%d", x.money); if (getdata_str(i++, 0, "�Ȧ�b��G", buf, 10, DOECHO, genbuf)) if ((l = atol(buf)) != 0) { if (l != x.money) { @@ -303,7 +303,7 @@ uinfo_query(userec_t * u, int real, int unum) } } } - sprintf(genbuf, "%d", x.exmailbox); + snprintf(genbuf, sizeof(genbuf), "%d", x.exmailbox); if (getdata_str(i++, 0, "�ʶR�H�c�ơG", buf, 4, DOECHO, genbuf)) if ((l = atol(buf)) != 0) x.exmailbox = (int)l; @@ -313,22 +313,22 @@ uinfo_query(userec_t * u, int real, int unum) getdata_buf(i++, 0, "�̪���{�����G", x.lasthost, sizeof(x.lasthost), DOECHO); - sprintf(genbuf, "%d", x.numlogins); + snprintf(genbuf, sizeof(genbuf), "%d", x.numlogins); if (getdata_str(i++, 0, "�W�u���ơG", buf, 10, DOECHO, genbuf)) if ((fail = atoi(buf)) >= 0) x.numlogins = fail; - sprintf(genbuf, "%d", u->numposts); + snprintf(genbuf, sizeof(genbuf), "%d", u->numposts); if (getdata_str(i++, 0, "�峹�ƥءG", buf, 10, DOECHO, genbuf)) if ((fail = atoi(buf)) >= 0) x.numposts = fail; - sprintf(genbuf, "%d", u->vl_count); + snprintf(genbuf, sizeof(genbuf), "%d", u->vl_count); if (getdata_str(i++, 0, "�H�k�O���G", buf, 10, DOECHO, genbuf)) if ((fail = atoi(buf)) >= 0) x.vl_count = fail; - sprintf(genbuf, "%d/%d/%d", u->five_win, u->five_lose, - u->five_tie); + snprintf(genbuf, sizeof(genbuf), + "%d/%d/%d", u->five_win, u->five_lose, u->five_tie); if (getdata_str(i++, 0, "���l�Ѿ��Z ��/��/�M�G", buf, 16, DOECHO, genbuf)) while (1) { @@ -346,7 +346,8 @@ uinfo_query(userec_t * u, int real, int unum) x.five_tie = atoi(p); break; } - sprintf(genbuf, "%d/%d/%d", u->chc_win, u->chc_lose, u->chc_tie); + snprintf(genbuf, sizeof(genbuf), + "%d/%d/%d", u->chc_win, u->chc_lose, u->chc_tie); if (getdata_str(i++, 0, "�H�Ѿ��Z ��/��/�M�G", buf, 16, DOECHO, genbuf)) while (1) { @@ -484,10 +485,11 @@ uinfo_query(userec_t * u, int real, int unum) if (i == QUIT) { char src[STRLEN], dst[STRLEN]; - sprintf(src, "home/%c/%s", x.userid[0], x.userid); - sprintf(dst, "tmp/%s", x.userid); + snprintf(src, sizeof(src), "home/%c/%s", x.userid[0], x.userid); + snprintf(dst, sizeof(dst), "tmp/%s", x.userid); if (Rename(src, dst)) { - sprintf(genbuf, "/bin/rm -fr %s >/dev/null 2>&1", src); + snprintf(genbuf, sizeof(genbuf), + "/bin/rm -fr %s >/dev/null 2>&1", src); /* * do not remove system(genbuf); */ @@ -521,8 +523,9 @@ uinfo_query(userec_t * u, int real, int unum) fprintf(fp, "\n \033[1;37m����%s�ק���z�ѬO�G%s\033[m", cuser.userid, reason); fclose(fp); - sprintf(fhdr.title, "[���w���i] ����%s�ק�%s�����i", cuser.userid, - x.userid); + snprintf(fhdr.title, sizeof(fhdr.title), + "[���w���i] ����%s�ק�%s�����i", cuser.userid, + x.userid); strlcpy(fhdr.owner, "[�t�Φw����]", sizeof(fhdr.owner)); append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr)); } @@ -723,10 +726,10 @@ getfield(int line, char *info, char *desc, char *buf, int len) char prompt[STRLEN]; char genbuf[200]; - sprintf(genbuf, "����]�w�G%-30.30s (%s)", buf, info); + snprintf(genbuf, sizeof(genbuf), "����]�w�G%-30.30s (%s)", buf, info); move(line, 2); outs(genbuf); - sprintf(prompt, "%s�G", desc); + snprintf(prompt, sizeof(prompt), "%s�G", desc); if (getdata_str(line + 1, 2, prompt, genbuf, len, DOECHO, buf)) strcpy(buf, genbuf); move(line, 2); @@ -899,14 +902,17 @@ toregister(char *email, char *genbuf, char *phone, char *career, if (phone != NULL) { #ifdef HAVEMOBILE if (strcmp(email, "m") == 0 || strcmp(email, "M") == 0) - sprintf(genbuf, "%s:%s:<Mobile>", phone, career); + sprintf(genbuf, sizeof(genbuf), + "%s:%s:<Mobile>", phone, career); else #endif - sprintf(genbuf, "%s:%s:<Email>", phone, career); + snprintf(genbuf, sizeof(genbuf), + "%s:%s:<Email>", phone, career); strncpy(cuser.justify, genbuf, REGLEN); sethomefile(buf, cuser.userid, "justify"); } - sprintf(buf, "�z�b " BBSNAME " ���{�ҽX: %s", getregcode(genbuf)); + snprintf(buf, sizeof(buf), + "�z�b " BBSNAME " ���{�ҽX: %s", getregcode(genbuf)); strlcpy(tmp, cuser.userid, sizeof(tmp)); strlcpy(cuser.userid, "SYSOP", sizeof(cuser.userid)); #ifdef HAVEMOBILE @@ -956,12 +962,12 @@ u_register(void) strlcpy(rname, cuser.realname, sizeof(rname)); strlcpy(addr, cuser.address, sizeof(addr)); strlcpy(email, cuser.email, sizeof(email)); - sprintf(mobile, "0%09d", cuser.mobile); + snprintf(mobile, sizeof(mobile), "0%09d", cuser.mobile); if (cuser.month == 0 && cuser.day && cuser.year == 0) birthday[0] = 0; else - sprintf(birthday, "%02i/%02i/%02i", - cuser.month, cuser.day, cuser.year % 100); + snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i", + cuser.month, cuser.day, cuser.year % 100); sex_is[0] = (cuser.sex % 8) + '1'; sex_is[1] = 0; career[0] = phone[0] = '\0'; @@ -1091,8 +1097,8 @@ u_register(void) getfield(15, "���/���/�褸 �p:09/27/76", "�ͤ�", birthday, 9); len = strlen(birthday); if (!len) { - sprintf(birthday, "%02i/%02i/%02i", - cuser.month, cuser.day, cuser.year % 100); + snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i", + cuser.month, cuser.day, cuser.year % 100); mon = cuser.month; day = cuser.day; year = cuser.year; diff --git a/mbbsd/vice.c b/mbbsd/vice.c index 35a5641f..acc653fa 100644 --- a/mbbsd/vice.c +++ b/mbbsd/vice.c @@ -1,4 +1,4 @@ -/* $Id: vice.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: vice.c,v 1.6 2002/07/22 19:02:01 in2 Exp $ */ #include "bbs.h" #define VICE_PLAY BBSHOME "/etc/vice/vice.play" @@ -54,7 +54,7 @@ ran_showfile(int y, int x, char *filename, int maxnum) char buf[512]; bzero(buf, sizeof(char) * 512); - sprintf(buf, "%s%d", filename, rand() % maxnum + 1); + snprintf(buf, sizeof(buf), "%s%d", filename, rand() % maxnum + 1); if (!(fs = fopen(buf, "r"))) { move(10, 10); prints("can't open file: %s", buf); @@ -74,7 +74,7 @@ ran_showmfile(char *filename, int maxnum) { char buf[256]; - sprintf(buf, "%s%d", filename, rand() % maxnum + 1); + snprintf(buf, sizeof(buf), "%s%d", filename, rand() % maxnum + 1); return more(buf, YEA); } diff --git a/mbbsd/vote.c b/mbbsd/vote.c index fb1c40e9..48afafd1 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -1,4 +1,4 @@ -/* $Id: vote.c,v 1.14 2002/07/21 20:43:35 kcwu Exp $ */ +/* $Id: vote.c,v 1.15 2002/07/22 19:02:01 in2 Exp $ */ #include "bbs.h" static int total; @@ -136,11 +136,12 @@ vote_report(char *bname, char *fname, char *fpath) memset(&header, 0, sizeof(fileheader_t)); strlcpy(header.owner, "[�������l]", sizeof(header.owner)); - sprintf(header.title, "[%s] �ݪO �ﱡ����", bname); + snprintf(header.title, sizeof(header.title), "[%s] �ݪO �ﱡ����", bname); { register struct tm *ptime = localtime(&dtime); - sprintf(header.date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); + snprintf(header.date, sizeof(header.date), + "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); } strlcpy(header.filename, ip, sizeof(header.filename)); @@ -261,10 +262,10 @@ b_result_one(boardheader_t * fh, int ind) b_suckinfile(frp, b_newresults); fclose(frp); } - sprintf(inbuf, "boards/%c/%s", bname[0], bname); + snprintf(inbuf, sizeof(inbuf), "boards/%c/%s", bname[0], bname); vote_report(bname, b_report, inbuf); if (!(fh->brdattr & BRD_NOCOUNT)) { - sprintf(inbuf, "boards/%c/%s", 'R', "Record"); + snprintf(inbuf, sizeof(inbuf), "boards/%c/%s", 'R', "Record"); vote_report(bname, b_report, inbuf); } unlink(b_report); @@ -493,8 +494,10 @@ vote_view_all(char *bname) fclose(xfp); } for (i = 1; i < 20; i++) { - sprintf(STR_new_control, "%s%d", STR_bv_control, i); - sprintf(STR_new_title, "%s%d", STR_bv_title, i); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, i); + snprintf(STR_new_title, sizeof(STR_new_title), + "%s%d", STR_bv_title, i); setbfile(buf, bname, STR_new_control); if ((fp = fopen(buf, "r"))) { prints("(%d) ", i); @@ -513,15 +516,16 @@ vote_view_all(char *bname) if (x < 0) return FULLUPDATE; - sprintf(buf, "�n�ݴX���벼 [%d] ", x); + snprintf(buf, sizeof(buf), "�n�ݴX���벼 [%d] ", x); getdata(b_lines - 1, 0, buf, genbuf, 4, LCECHO); if (atoi(genbuf) < 0 || atoi(genbuf) > 20) - sprintf(genbuf, "%d", x); + snprintf(genbuf, sizeof(genbuf), "%d", x); if (genbuf[0] != '0') - sprintf(STR_new_control, "%s%d", STR_bv_control, atoi(genbuf)); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, atoi(genbuf)); else strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); @@ -576,13 +580,20 @@ vote_maintain(char *bname) unlink(buf); for (i = 1; i < 20; i++) { - sprintf(STR_new_ballots, "%s%d", STR_bv_ballots, i); - sprintf(STR_new_control, "%s%d", STR_bv_control, i); - sprintf(STR_new_desc, "%s%d", STR_bv_desc, i); - sprintf(STR_new_flags, "%s%d", STR_bv_flags, i); - sprintf(STR_new_comments, "%s%d", STR_bv_comments, i); - sprintf(STR_new_limited, "%s%d", STR_bv_limited, i); - sprintf(STR_new_title, "%s%d", STR_bv_title, i); + snprintf(STR_new_ballots, sizeof(STR_new_ballots), + "%s%d", STR_bv_ballots, i); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, i); + snprintf(STR_new_desc, sizeof(STR_new_desc), + "%s%d", STR_bv_desc, i); + snprintf(STR_new_flags, sizeof(STR_new_flags), + "%s%d", STR_bv_flags, i); + snprintf(STR_new_comments, sizeof(STR_new_comments), + "%s%d", STR_bv_comments, i); + snprintf(STR_new_limited, sizeof(STR_new_limited), + "%s%d", STR_bv_limited, i); + snprintf(STR_new_title, sizeof(STR_new_title), + "%s%d", STR_bv_title, i); setbfile(buf, bname, STR_new_control); unlink(buf); @@ -610,7 +621,8 @@ vote_maintain(char *bname) while (x < 20 && (fp = fopen(buf, "r")) != NULL) { fclose(fp); x++; - sprintf(STR_new_control, "%s%d", STR_bv_control, x); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, x); setbfile(buf, bname, STR_new_control); } if (fp) @@ -689,7 +701,7 @@ vote_maintain(char *bname) outs("\n�Ш̧ǿ�J�ﶵ, �� ENTER �����]�w"); num = 0; while (!aborted) { - sprintf(buf, "%c) ", num + 'A'); + snprintf(buf, sizeof(buf), "%c) ", num + 'A'); getdata((num % 15) + 2, (num / 15) * 40, buf, inbuf, 50, DOECHO); if (*inbuf) { @@ -699,7 +711,7 @@ vote_maintain(char *bname) if ((*inbuf == '\0' && num >= 1) || num == 30) aborted = 1; } - sprintf(buf, "�аݨC�H�̦h�i��X���H([1]��%d): ", num); + snprintf(buf, sizeof(buf), "�аݨC�H�̦h�i��X���H([1]��%d): ", num); getdata(t_lines - 3, 0, buf, inbuf, 3, DOECHO); @@ -990,8 +1002,10 @@ user_vote(char *bname) fclose(xfp); } for (i = 1; i < 20; i++) { - sprintf(STR_new_control, "%s%d", STR_bv_control, i); - sprintf(STR_new_title, "%s%d", STR_bv_title, i); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, i); + snprintf(STR_new_title, sizeof(STR_new_title), + "%s%d", STR_bv_title, i); setbfile(buf, bname, STR_new_control); if ((fp = fopen(buf, "r"))) { prints("(%d) ", i); @@ -1011,15 +1025,16 @@ user_vote(char *bname) if (x < 0) return FULLUPDATE; - sprintf(buf, "�n��X���벼 [%d] ", x); + snprintf(buf, sizeof(buf), "�n��X���벼 [%d] ", x); getdata(b_lines - 1, 0, buf, genbuf, 4, LCECHO); if (atoi(genbuf) < 0 || atoi(genbuf) > 20) - sprintf(genbuf, "%d", x); + snprintf(genbuf, sizeof(genbuf), "%d", x); if (genbuf[0] != '0') - sprintf(STR_new_control, "%s%d", STR_bv_control, atoi(genbuf)); + snprintf(STR_new_control, sizeof(STR_new_control), + "%s%d", STR_bv_control, atoi(genbuf)); else strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 6a7d7b87..27ca0bd3 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -1,4 +1,4 @@ -/* $Id: voteboard.c,v 1.12 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: voteboard.c,v 1.13 2002/07/22 19:02:01 in2 Exp $ */ #include "bbs.h" #define VOTEBOARD "NewBoard" @@ -225,8 +225,9 @@ do_voteboard() else break; } while (temp > 0); - sprintf(title, "[�ӽзs�O] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s", "�ӽзs�O", "�^��W��: ", topic, "����W��: "); + snprintf(title, sizeof(title), "[�ӽзs�O] %s", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n%s", "�ӽзs�O", "�^��W��: ", topic, "����W��: "); if (!getdata(5, 0, "�п�J�ݪO����W�١G", topic, 20, DOECHO)) return FULLUPDATE; @@ -258,8 +259,9 @@ do_voteboard() else break; } while (temp > 0); - sprintf(title, "[�o���ªO] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n", "�o���ªO", "�^��W��: ", topic); + snprintf(title, sizeof(title), "[�o���ªO] %s", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n", "�o���ªO", "�^��W��: ", topic); strcat(genbuf, "\n�o����]: \n"); outs("�п�J�o����](�ܦh����)�A�n�M����g���M���|�֭��"); for (i = 8; i < 13; i++) { @@ -281,8 +283,8 @@ do_voteboard() else break; } while (temp > 0); - sprintf(title, "[�s�p�O�D] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s%s", "�s�p�O�D", "�^��W��: ", topic, "�ӽ� ID : ", cuser.userid); + snprintf(title, sizeof(title), "[�s�p�O�D] %s", topic); + snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "�s�p�O�D", "�^��W��: ", topic, "�ӽ� ID : ", cuser.userid); strcat(genbuf, "\n�ӽЬF��: \n"); outs("�п�J�ӽЬF��(�ܦh����)�A�n�M����g���M���|�֭��"); for (i = 8; i < 13; i++) { @@ -303,8 +305,10 @@ do_voteboard() else break; } while (temp > 0); - sprintf(title, "[�}�K�O�D] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s", "�}�K�O�D", "�^��W��: ", topic, "�O�D ID : "); + snprintf(title, sizeof(title), "[�}�K�O�D] %s", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n%s", "�}�K�O�D", "�^��W��: ", + topic, "�O�D ID : "); do { if (!getdata(6, 0, "�п�J�O�DID�G", topic, IDLEN + 1, DOECHO)) return FULLUPDATE; @@ -328,8 +332,10 @@ do_voteboard() case 5: if (!getdata(4, 0, "�п�J�p�դ��^��W�١G", topic, 30, DOECHO)) return FULLUPDATE; - sprintf(title, "[�s�p�p�ժ�] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s%s", "�s�p�p�ժ�", "�p�զW��: ", topic, "�ӽ� ID : ", cuser.userid); + snprintf(title, sizeof(title), "[�s�p�p�ժ�] %s", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n%s%s", "�s�p�p�ժ�", "�p�զW��: ", + topic, "�ӽ� ID : ", cuser.userid); strcat(genbuf, "\n�ӽЬF��: \n"); outs("�п�J�ӽЬF��(�ܦh����)�A�n�M����g���M���|�֭��"); for (i = 8; i < 13; i++) { @@ -345,8 +351,9 @@ do_voteboard() if (!getdata(4, 0, "�п�J�p�դ��^��W�١G", topic, 30, DOECHO)) return FULLUPDATE; - sprintf(title, "[�}�K�p�ժ�] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s", "�}�K�p�ժ�", "�p�զW��: ", topic, "�p�ժ� ID : "); + snprintf(title, sizeof(title), "[�}�K�p�ժ�] %s", topic); + snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s", + "�}�K�p�ժ�", "�p�զW��: ", topic, "�p�ժ� ID : "); if (!getdata(6, 0, "�п�J�p�ժ�ID�G", topic, IDLEN + 1, DOECHO)) return FULLUPDATE; strcat(genbuf, topic); @@ -366,8 +373,9 @@ do_voteboard() return FULLUPDATE; if (!getdata(4, 0, "�п�J����D�D�G", topic, 30, DOECHO)) return FULLUPDATE; - sprintf(title, "%s %s", "[��������]", topic); - sprintf(genbuf, "%s\n\n%s%s\n", "��������", "����D�D: ", topic); + snprintf(title, sizeof(title), "%s %s", "[��������]", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n", "��������", "����D�D: ", topic); strcat(genbuf, "\n�����]: \n"); outs("�п�J�����](�ܦh����)�A�n�M����g���M���|�֭��"); for (i = 8; i < 13; i++) { @@ -382,8 +390,9 @@ do_voteboard() case 8: if (!getdata(4, 0, "�п�J�s�դ��^��W�١G", topic, 30, DOECHO)) return FULLUPDATE; - sprintf(title, "[�ӽзs�s��] %s", topic); - sprintf(genbuf, "%s\n\n%s%s\n%s%s", "�ӽиs��", "�s�զW��: ", topic, "�ӽ� ID : ", cuser.userid); + snprintf(title, sizeof(title), "[�ӽзs�s��] %s", topic); + snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", + "�ӽиs��", "�s�զW��: ", topic, "�ӽ� ID : ", cuser.userid); strcat(genbuf, "\n�ӽЬF��: \n"); outs("�п�J�ӽЬF��(�ܦh����)�A�n�M����g���M���|�֭��"); for (i = 8; i < 13; i++) { @@ -400,7 +409,7 @@ do_voteboard() } strcat(genbuf, "�s�p�����ɶ�: "); now += 14 * 24 * 60 * 60; - sprintf(topic, "(%ld)", now); + snprintf(topic, sizeof(topic), "(%ld)", now); strcat(genbuf, topic); strcat(genbuf, ctime(&now)); now -= 14 * 24 * 60 * 60; diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c index e277421d..dba8ad13 100644 --- a/mbbsd/xyz.c +++ b/mbbsd/xyz.c @@ -1,4 +1,4 @@ -/* $Id: xyz.c,v 1.11 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: xyz.c,v 1.12 2002/07/22 19:02:01 in2 Exp $ */ #include "bbs.h" /* �U�زέp�ά�����T�C�� */ @@ -230,13 +230,13 @@ note() collect = 1; while (total) { - sprintf(buf, "\033[1;31m�~�t\033[32m %s \033[37m(%s)", + snprintf(buf, sizeof(buf), "\033[1;31m�~�t\033[32m %s \033[37m(%s)", myitem.userid, myitem.username); len = strlen(buf); for (i = len; i < 73; i++) strcat(buf, " "); - sprintf(buf2, " \033[1;36m%.14s\033[31m �u��\033[m\n", + snprintf(buf2, sizeof(buf2), " \033[1;36m%.14s\033[31m �u��\033[m\n", Cdate(&(myitem.date))); strcat(buf, buf2); fputs(buf, fp); @@ -444,7 +444,7 @@ x_archie() exec_cmd(ARCHIE, YEA, "bin/archie.sh", ARCHIE); log_usies("ARCHIE", ""); strcpy(genbuf1, buf); - sprintf(buf, BBSHOME "/tmp/archie.%s", cuser.userid); + snprintf(buf, sizeof(buf), BBSHOME "/tmp/archie.%s", cuser.userid); if (dashf(buf)) { getdata(0, 0, "�n�N���G�H�^�H�c��(Y/N)�H[N]", ans, sizeof(ans), DOECHO, 0); @@ -456,7 +456,8 @@ x_archie() sethomepath(buf1, cuser.userid); stampfile(buf1, &mhdr); strcpy(mhdr.owner, cuser.userid); - sprintf(genbuf2, "Archie �j�M�ɮ�: %s ���G", genbuf1); + sprintf(genbuf2, sizeof(genbuf2), + "Archie �j�M�ɮ�: %s ���G", genbuf1); strcpy(mhdr.title, genbuf2); mhdr.filemode = 0; sethomedir(title, cuser.userid); |