summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/aids.c4
-rw-r--r--mbbsd/bbslua.c3
-rw-r--r--mbbsd/cache.c5
-rw-r--r--mbbsd/pmore.c2
-rw-r--r--mbbsd/record.c2
-rw-r--r--mbbsd/screen.c5
6 files changed, 9 insertions, 12 deletions
diff --git a/mbbsd/aids.c b/mbbsd/aids.c
index 2b5baac7..56d19378 100644
--- a/mbbsd/aids.c
+++ b/mbbsd/aids.c
@@ -235,8 +235,8 @@ SearchAIDResult_t do_search_aid(void)
aidu = aidc2aidu(sp);
if((sp2 = strchr(sp, '@')) != NULL)
{
- strncpy(bname, sp2 + 1, IDLEN);
- bname[IDLEN] = '\0';
+ // assert(sizeof(bname) > IDLEN);
+ strlcpy(bname, sp2 + 1, IDLEN+1);
*sp2 = '\0';
}
else
diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c
index ebe8e23c..084b7698 100644
--- a/mbbsd/bbslua.c
+++ b/mbbsd/bbslua.c
@@ -418,8 +418,7 @@ bl_getstr(lua_State* L)
* this part now done in getdata_str
if (pmsg && *pmsg)
{
- strncpy(buf, pmsg, sizeof(buf)-1);
- buf[sizeof(buf)-1] = 0;
+ strlcpy(buf, pmsg, sizeof(buf));
}
*/
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 6b5ef343..ca43a089 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -995,11 +995,10 @@ reload_fcache(void)
}
ip = strtok_r(NULL, " \t", &strtok_pos);
if (ip == NULL) {
- strncpy(SHM->home_desc[SHM->home_num], "雲深不知處",
- sizeof(SHM->home_desc[SHM->home_num]));
+ strcpy(SHM->home_desc[SHM->home_num], "雲深不知處");
}
else {
- strncpy(SHM->home_desc[SHM->home_num], ip,
+ strlcpy(SHM->home_desc[SHM->home_num], ip,
sizeof(SHM->home_desc[SHM->home_num]));
chomp(SHM->home_desc[SHM->home_num]);
}
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index e5aae141..69be7b2f 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -1404,7 +1404,7 @@ mf_display()
char buf[64]; // make sure ptt_prints will not exceed
memset(buf, 0, sizeof(buf));
- strncpy(buf, (char*)mf.dispe, 3); // ^[[*s
+ memcpy(buf, mf.dispe, 3); // ^[*s
mf.dispe += 2;
if(bpref.rawmode)
diff --git a/mbbsd/record.c b/mbbsd/record.c
index 65c139cd..d50df1d9 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -578,9 +578,9 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char *
int n;
for (n = strlen(fpath) - 1; fpath[n] != '/' && n > 0; n--);
- strncpy(buf, fpath, n + 1);
if (n + sizeof(".forward") > sizeof(buf))
return -1;
+ memcpy(buf, fpath, n+1);
strcpy(buf + n + 1, ".forward");
if ((fp = fopen(buf, "r"))) {
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 76a4f34f..8b518070 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -664,7 +664,7 @@ innstr(char *str, int n)
slp->data[slp->len] = 0;
strip_ansi(buf, (char*)slp->data, STRIP_ALL);
buf[ANSILINELEN] = 0;
- strncpy(str, buf, n);
+ strlcpy(str, buf, n);
return strlen(str);
}
@@ -676,8 +676,7 @@ inansistr(char *str, int n)
if (!slp)
return 0;
slp->data[slp->len] = 0;
- strncpy(str, (char*)slp->data, n);
- str[n] = 0;
+ strlcpy(str, (char*)slp->data, n);
return strlen(str);
}