diff options
-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)) { |