diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-07-13 14:19:40 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-07-13 14:19:40 +0800 |
commit | 91515a92e554a74f73a15212bea26006f373c5d8 (patch) | |
tree | 4ce0925f3b7c7596d52904a8baff11ebf272861e | |
parent | 9df723341d8c6e51598323107382038719ec2f46 (diff) | |
download | pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar.gz pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar.bz2 pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar.lz pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar.xz pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.tar.zst pttbbs-91515a92e554a74f73a15212bea26006f373c5d8.zip |
Fix incorrect snprintf usage.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5852 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/ccw.c | 3 | ||||
-rw-r--r-- | pttbbs/util/outmail.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/pttbbs/mbbsd/ccw.c b/pttbbs/mbbsd/ccw.c index 137e9d44..8155e75a 100644 --- a/pttbbs/mbbsd/ccw.c +++ b/pttbbs/mbbsd/ccw.c @@ -778,6 +778,9 @@ ccw_chat_send(CCW_CTX *ctx, const char *buf) char genbuf[200]; len = snprintf(genbuf, sizeof(genbuf), "%s\n", buf); + assert(len < sizeof(genbuf)); + if (len > sizeof(genbuf)) + len = sizeof(genbuf); // XXX if remote is closed (without MSG_NOSIGNAL), // this may raise a SIGPIPE and cause BBS to abort... return (tosend(ctx->fd, genbuf, len, MSG_NOSIGNAL) == len); diff --git a/pttbbs/util/outmail.c b/pttbbs/util/outmail.c index fe2d05f6..48adb6e2 100644 --- a/pttbbs/util/outmail.c +++ b/pttbbs/util/outmail.c @@ -101,6 +101,9 @@ void doSendBody(int sock, FILE *fp, char *from, char *to, char *subject) { starttime, (msgid += (int)(random() >> 24)), disclaimer); + assert(n < sizeof(buf)); + if (n > sizeof(buf)) + n = sizeof(buf); write(sock, buf, n); while(fgets(buf, sizeof(buf), fp)) { |