From 927c9665ce01fdade6a0846ad60a561320272440 Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 12 Jan 2006 05:00:08 +0000 Subject: replace some strncpy with strlcpy, or just strcpy if src is const git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3267 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'mbbsd/bbs.c') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 965eb0fd..6f32deae 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -734,7 +734,7 @@ do_general(int isbid) move(21,0); outs("種類:"); for(i=0; i<8 && bp->posttype[i*4]; i++) - strncpy(ctype[i],bp->posttype+4*i,4); + strlcpy(ctype[i],bp->posttype+4*i,5); if(i==0) i=8; for(aborted=0; abortedposttype + i * 4, 4); - genbuf[4] = 0; + strlcpy(genbuf, bp->posttype + i * 4, 5); sprintf(title, "%d.", i + 1); if( !getdata_buf(2, 11, title, genbuf, 5, DOECHO) ) break; @@ -1081,7 +1080,7 @@ b_posttype(int ent, const fileheader_t * fhdr, const char *direct) posttype_f |= (1<posttype_f = posttype_f; - strncpy(bp->posttype, posttype, 32); /* 這邊應該要防race condition */ + strlcpy(bp->posttype, posttype, sizeof(bp->posttype)); /* 這邊應該要防race condition */ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); return FULLUPDATE; @@ -1503,7 +1502,7 @@ read_post(int ent, fileheader_t * fhdr, const char *direct) STATINC(STAT_READPOST_OLD); } brc_addlist(fhdr->filename); - strncpy(currtitle, subject(fhdr->title), TTLEN); + strlcpy(currtitle, subject(fhdr->title), sizeof(currtitle)); switch(more_result) { @@ -2294,7 +2293,7 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) #endif lastrecommend = now; lastrecommend_bid = currbid; - strncpy(lastrecommend_fname, fhdr->filename, FNLEN); + strlcpy(lastrecommend_fname, fhdr->filename, sizeof(lastrecommend_fname)); return FULLUPDATE; } -- cgit v1.2.3