diff options
-rw-r--r-- | include/bbs.h | 13 | ||||
-rw-r--r-- | mbbsd/admin.c | 6 | ||||
-rw-r--r-- | mbbsd/args.c | 4 | ||||
-rw-r--r-- | mbbsd/io.c | 4 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 6 | ||||
-rw-r--r-- | mbbsd/name.c | 4 | ||||
-rw-r--r-- | mbbsd/screen.c | 4 | ||||
-rw-r--r-- | mbbsd/vote.c | 60 |
8 files changed, 56 insertions, 45 deletions
diff --git a/include/bbs.h b/include/bbs.h index 7d2ef8d1..023ac1a2 100644 --- a/include/bbs.h +++ b/include/bbs.h @@ -49,5 +49,16 @@ #else #include <limits.h> #endif - +#ifdef DEBUG +static int Sizeof(char *what,int size,char *file,int line) +{ + if(size==4) + printf("WARRNING\r\n"); + printf("%s(%d): sizeof(%s)=%d\r\n",file,line,what,size); + return size; +} +#define SIZEOF(a) Sizeof(#a,sizeof(a),__FILE__,__LINE__) +#else +#define SIZEOF(a) sizeof(a) +#endif #endif /* INCLUDE_BBS_H */ diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 8fe3621c..a9fe35ca 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -1,4 +1,4 @@ -/* $Id: admin.c,v 1.27 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: admin.c,v 1.28 2002/07/21 20:39:34 kcwu Exp $ */ #include "bbs.h" /* 使用者管理 */ @@ -275,7 +275,7 @@ m_mod_board(char *bname) if (genbuf[0] != 'y' || !bname[0]) outs(MSG_DEL_CANCEL); else { - strlcpy(bname, bh.brdname, sizeof(bname)); + strlcpy(bname, bh.brdname, SIZEOF(bname)); sprintf(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", @@ -777,7 +777,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'; } diff --git a/mbbsd/args.c b/mbbsd/args.c index d1291176..e517b512 100644 --- a/mbbsd/args.c +++ b/mbbsd/args.c @@ -1,4 +1,4 @@ -/* $Id: args.c,v 1.5 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: args.c,v 1.6 2002/07/21 20:39:34 kcwu 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(Argv[0]); p = &Argv[0][i]; while (p < LastArgv) *p++ = '\0'; @@ -1,4 +1,4 @@ -/* $Id: io.c,v 1.20 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: io.c,v 1.21 2002/07/21 20:39:34 kcwu 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)); + strlcpy(buf, hc_convert_str(buf, HC_GBtoBIG, HC_DO_SINGLE), SIZEOF(buf)); } #endif return clen; diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 012974ec..6b3e15f3 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1,4 +1,4 @@ -/* $Id: mbbsd.c,v 1.42 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: mbbsd.c,v 1.43 2002/07/21 20:39:34 kcwu Exp $ */ #include "bbs.h" #define SOCKET_QLEN 4 @@ -733,7 +733,7 @@ setup_utmp(int mode) #ifndef FAST_LOGIN setuserfile(buf, "remoteuser"); - strlcpy(remotebuf, fromhost, sizeof(remotebuf)); + strlcpy(remotebuf, fromhost, SIZEOF(remotebuf)); strcat(remotebuf, ctime(&now)); remotebuf[strlen(remotebuf) - 1] = 0; add_distinct(buf, remotebuf); @@ -1114,7 +1114,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(rname)); } } alarm(0); diff --git a/mbbsd/name.c b/mbbsd/name.c index 446a136f..72aba76c 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -1,4 +1,4 @@ -/* $Id: name.c,v 1.12 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: name.c,v 1.13 2002/07/21 20:39:34 kcwu 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/screen.c b/mbbsd/screen.c index 2650f5f9..59032a85 100644 --- a/mbbsd/screen.c +++ b/mbbsd/screen.c @@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.6 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: screen.c,v 1.7 2002/07/21 20:39:34 kcwu 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(buf)); } #define NORMAL (00) diff --git a/mbbsd/vote.c b/mbbsd/vote.c index f2af6047..29d648a5 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -1,4 +1,4 @@ -/* $Id: vote.c,v 1.12 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: vote.c,v 1.13 2002/07/21 20:39:34 kcwu Exp $ */ #include "bbs.h" static int total; @@ -180,13 +180,13 @@ b_result_one(boardheader_t * fh, int ind) fh->bvote = 1; if (ind) { - sprintf(STR_new_ballots, "%s%d", STR_bv_ballots, ind); - sprintf(STR_new_control, "%s%d", STR_bv_control, ind); - sprintf(STR_new_desc, "%s%d", STR_bv_desc, ind); - sprintf(STR_new_flags, "%s%d", STR_bv_flags, ind); - sprintf(STR_new_comments, "%s%d", STR_bv_comments, ind); - sprintf(STR_new_limited, "%s%d", STR_bv_limited, ind); - sprintf(STR_new_title, "%s%d", STR_bv_title, ind); + snprintf(STR_new_ballots, sizeof(STR_new_ballots), "%s%d", STR_bv_ballots, ind); + snprintf(STR_new_control, sizeof(STR_new_control),"%s%d", STR_bv_control, ind); + snprintf(STR_new_desc, sizeof(STR_new_desc), "%s%d", STR_bv_desc, ind); + snprintf(STR_new_flags, sizeof(STR_new_flags), "%s%d", STR_bv_flags, ind); + snprintf(STR_new_comments, sizeof(STR_new_comments), "%s%d", STR_bv_comments, ind); + snprintf(STR_new_limited, sizeof(STR_new_limited), "%s%d", STR_bv_limited, ind); + snprintf(STR_new_title, sizeof(STR_new_title), "%s%d", STR_bv_title, ind); } else { strlcpy(STR_new_ballots, STR_bv_ballots, sizeof(STR_new_ballots)); strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); @@ -287,7 +287,7 @@ b_result(boardheader_t * fh) for (i = 0; i < 20; i++) { if (i) - sprintf(STR_new_control, "%s%d", STR_bv_control, i); + sprintf(STR_new_control, sizeof(STR_new_control), "%s%d", STR_bv_control, i); else strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); @@ -367,13 +367,13 @@ vote_view(char *bname, int index) time_t closetime; if (index) { - sprintf(STR_new_ballots, "%s%d", STR_bv_ballots, index); - sprintf(STR_new_control, "%s%d", STR_bv_control, index); - sprintf(STR_new_desc, "%s%d", STR_bv_desc, index); - sprintf(STR_new_flags, "%s%d", STR_bv_flags, index); - sprintf(STR_new_comments, "%s%d", STR_bv_comments, index); - sprintf(STR_new_limited, "%s%d", STR_bv_limited, index); - sprintf(STR_new_title, "%s%d", STR_bv_title, index); + sprintf(STR_new_ballots, sizeof(STR_new_ballots),"%s%d", STR_bv_ballots, index); + sprintf(STR_new_control, sizeof(STR_new_control), "%s%d", STR_bv_control, index); + sprintf(STR_new_desc, sizeof(STR_new_desc), "%s%d", STR_bv_desc, index); + sprintf(STR_new_flags, sizeof(STR_new_flags), "%s%d", STR_bv_flags, index); + sprintf(STR_new_comments, sizeof(STR_new_comments), "%s%d", STR_bv_comments, index); + sprintf(STR_new_limited, sizeof(STR_new_limited), "%s%d", STR_bv_limited, index); + sprintf(STR_new_title, sizeof(STR_new_title), "%s%d", STR_bv_title, index); } else { strlcpy(STR_new_ballots, STR_bv_ballots, sizeof(STR_new_ballots)); strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); @@ -618,13 +618,13 @@ vote_maintain(char *bname) if (x >= 20) return FULLUPDATE; if (x) { - sprintf(STR_new_ballots, "%s%d", STR_bv_ballots, x); - sprintf(STR_new_control, "%s%d", STR_bv_control, x); - sprintf(STR_new_desc, "%s%d", STR_bv_desc, x); - sprintf(STR_new_flags, "%s%d", STR_bv_flags, x); - sprintf(STR_new_comments, "%s%d", STR_bv_comments, x); - sprintf(STR_new_limited, "%s%d", STR_bv_limited, x); - sprintf(STR_new_title, "%s%d", STR_bv_title, x); + sprintf(STR_new_ballots, sizeof(STR_new_ballots), "%s%d", STR_bv_ballots, x); + sprintf(STR_new_control, sizeof(STR_new_control), "%s%d", STR_bv_control, x); + sprintf(STR_new_desc, sizeof(STR_new_desc), "%s%d", STR_bv_desc, x); + sprintf(STR_new_flags, sizeof(STR_new_flags), "%s%d", STR_bv_flags, x); + sprintf(STR_new_comments, sizeof(STR_new_comments), "%s%d", STR_bv_comments, x); + sprintf(STR_new_limited, sizeof(STR_new_limited), "%s%d", STR_bv_limited, x); + sprintf(STR_new_title, sizeof(STR_new_title), "%s%d", STR_bv_title, x); } else { strlcpy(STR_new_ballots, STR_bv_ballots, sizeof(STR_new_ballots)); strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); @@ -734,7 +734,7 @@ vote_flag(char *bname, int index, char val) int fd, num, size; if (index) - sprintf(STR_new_flags, "%s%d", STR_bv_flags, index); + sprintf(STR_new_flags, sizeof(STR_new_flags), "%s%d", STR_bv_flags, index); else strlcpy(STR_new_flags, STR_bv_flags, sizeof(STR_new_flags)); @@ -784,12 +784,12 @@ user_vote_one(char *bname, int ind) time_t closetime; if (ind) { - sprintf(STR_new_ballots, "%s%d", STR_bv_ballots, ind); - sprintf(STR_new_control, "%s%d", STR_bv_control, ind); - sprintf(STR_new_desc, "%s%d", STR_bv_desc, ind); - sprintf(STR_new_flags, "%s%d", STR_bv_flags, ind); - sprintf(STR_new_comments, "%s%d", STR_bv_comments, ind); - sprintf(STR_new_limited, "%s%d", STR_bv_limited, ind); + sprintf(STR_new_ballots, sizeof(STR_new_ballots), "%s%d", STR_bv_ballots, ind); + sprintf(STR_new_control, sizeof(STR_new_control), "%s%d", STR_bv_control, ind); + sprintf(STR_new_desc, sizeof(STR_new_desc), "%s%d", STR_bv_desc, ind); + sprintf(STR_new_flags, sizeof(STR_new_flags),"%s%d", STR_bv_flags, ind); + sprintf(STR_new_comments, sizeof(STR_new_comments), "%s%d", STR_bv_comments, ind); + sprintf(STR_new_limited, sizeof(STR_new_limited), "%s%d", STR_bv_limited, ind); } else { strlcpy(STR_new_ballots, STR_bv_ballots, sizeof(STR_new_ballots)); strlcpy(STR_new_control, STR_bv_control, sizeof(STR_new_control)); |