summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-28 16:47:45 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-06-28 16:47:45 +0800
commit2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91 (patch)
tree87e9a623c3a4426e104f87511e2b66f86f75a829
parentc5f8b96c358e673945943d92c4ba562eba1f96ec (diff)
downloadpttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar.gz
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar.bz2
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar.lz
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar.xz
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.tar.zst
pttbbs-2dea9dc6eeee3dcd9a0ebc32dcee9723c4787c91.zip
assert() the return value of strchr() strrchr()
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@982 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c6
-rw-r--r--mbbsd/edit.c3
-rw-r--r--mbbsd/record.c10
-rw-r--r--mbbsd/stuff.c8
-rw-r--r--mbbsd/voteboard.c5
5 files changed, 23 insertions, 9 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 00343018..b89cbbef 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1,4 +1,4 @@
-/* $Id: bbs.c,v 1.100 2003/06/27 02:39:26 in2 Exp $ */
+/* $Id: bbs.c,v 1.101 2003/06/28 08:47:45 kcwu Exp $ */
#include "bbs.h"
static int recommend(int ent, fileheader_t * fhdr, char *direct);
@@ -1846,7 +1846,9 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
memcpy(&digest, fhdr, sizeof(digest));
digest.filename[0] = 'G';
strlcpy(buf, direct, sizeof(buf));
- ptr = strrchr(buf, '/') + 1;
+ ptr = strrchr(buf, '/');
+ assert(ptr);
+ ptr++;
ptr[0] = '\0';
snprintf(genbuf, sizeof(genbuf), "%s%s", buf, digest.filename);
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 738cb4f8..c3e2fdc5 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1,4 +1,4 @@
-/* $Id: edit.c,v 1.35 2003/06/25 22:56:19 kcwu Exp $ */
+/* $Id: edit.c,v 1.36 2003/06/28 08:47:45 kcwu Exp $ */
/* edit.c, 用來提供 bbs上的文字編輯器, 即 ve.
* 現在這一個是惡搞過的版本, 比較不穩定, 用比較多的 cpu, 但是可以省下許多
* 的記憶體 (以 Ptt為例, 在九千人上站的時候, 約可省下 50MB 的記憶體)
@@ -700,6 +700,7 @@ do_quote()
if ((curredit & EDIT_BOTH) && (str = strchr(quote_user, '.'))) {
strcpy(++str, ptr);
str = strchr(str, ' ');
+ assert(str);
str[0] = '\0';
}
} else
diff --git a/mbbsd/record.c b/mbbsd/record.c
index 61f58dbc..2bd06b16 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -1,4 +1,4 @@
-/* $Id: record.c,v 1.13 2003/02/27 10:48:41 victor Exp $ */
+/* $Id: record.c,v 1.14 2003/06/28 08:47:45 kcwu Exp $ */
#include "bbs.h"
#undef HAVE_MMAP
@@ -42,7 +42,9 @@ get_sum_records(char *fpath, int size)
return -1;
strlcpy(buf, fpath, sizeof(buf));
- p = strrchr(buf, '/') + 1;
+ p = strrchr(buf, '/');
+ assert(p);
+ p++;
while (fread(&fhdr, size, 1, fp) == 1) {
strcpy(p, fhdr.filename);
@@ -275,7 +277,9 @@ delete_range(char *fpath, int id1, int id2)
}
count = 1;
strlcpy(fullpath, fpath, sizeof(fullpath));
- t = strrchr(fullpath, '/') + 1;
+ t = strrchr(fullpath, '/');
+ assert(t);
+ t++;
while (read(fdr, &fhdr, sizeof(fileheader_t)) == sizeof(fileheader_t)) {
strcpy(t, fhdr.filename);
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index f79ec1ae..a254b42c 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -1,4 +1,4 @@
-/* $Id: stuff.c,v 1.11 2003/03/26 10:22:42 in2 Exp $ */
+/* $Id: stuff.c,v 1.12 2003/06/28 08:47:45 kcwu Exp $ */
#include "bbs.h"
/* ----------------------------------------------------- */
@@ -78,11 +78,17 @@ setbfile(char *buf, char *boardname, char *fname)
sprintf(buf, str_board_file, boardname[0], boardname, fname);
}
+/*
+ * input direct
+ * output buf: copy direct
+ * fname: direct 的檔名部分
+ */
void
setdirpath(char *buf, char *direct, char *fname)
{
strcpy(buf, direct);
direct = strrchr(buf, '/');
+ assert(direct);
strcpy(direct + 1, fname);
}
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index eac92529..d477a12d 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -1,4 +1,4 @@
-/* $Id: voteboard.c,v 1.17 2003/03/17 13:41:04 victor Exp $ */
+/* $Id: voteboard.c,v 1.18 2003/06/28 08:47:45 kcwu Exp $ */
#include "bbs.h"
#define VOTEBOARD "NewBoard"
@@ -41,10 +41,11 @@ do_voteboardreply(fileheader_t * fhdr)
len = strlen(cuser.userid);
- while (fgets(genbuf, 1024, fp)) {
+ while (fgets(genbuf, sizeof(genbuf), fp)) {
if (!strncmp(genbuf, "連署結束時間", 12)) {
hastime = 1;
ptr = strchr(genbuf, '(');
+ assert(ptr);
sscanf(ptr + 1, "%ld", &endtime);
if (endtime < now) {
prints("連署時間已過");