diff options
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | mbbsd/bbs.c | 4 | ||||
-rw-r--r-- | mbbsd/cal.c | 2 | ||||
-rw-r--r-- | mbbsd/mail.c | 44 | ||||
-rw-r--r-- | mbbsd/record.c | 2 | ||||
-rw-r--r-- | mbbsd/register.c | 2 | ||||
-rw-r--r-- | mbbsd/user.c | 2 |
7 files changed, 31 insertions, 27 deletions
diff --git a/include/proto.h b/include/proto.h index d577f36f..92c9716d 100644 --- a/include/proto.h +++ b/include/proto.h @@ -348,7 +348,7 @@ int mail_id(const char* id, const char *title, const char *filename, const char int m_read(void); int doforward(const char *direct, const fileheader_t *fh, int mode); int mail_reply(int ent, fileheader_t *fhdr, const char *direct); -int bsmtp(const char *fpath, const char *title, const char *rcpt, int method); +int bsmtp(const char *fpath, const char *title, const char *rcpt); void hold_mail(const char *fpath, const char *receiver); void m_init(void); int chkmailbox(void); diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index f89c12b1..f342527c 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -900,7 +900,7 @@ do_general(int isbid) #ifndef USE_BSMTP bbs_sendmail(fpath, save_title, str + 1) #else - bsmtp(fpath, save_title, str + 1, 0) + bsmtp(fpath, save_title, str + 1) #endif < 0) msg = "作者無法收信"; @@ -3466,6 +3466,6 @@ Select(void) void mobile_message(const char *mobile, char *message) { - bsmtp(char *fpath, char *title, char *rcpt, int method); + bsmtp(fpath, title, rcpt); } #endif diff --git a/mbbsd/cal.c b/mbbsd/cal.c index 83b739f6..b2a92d92 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -235,7 +235,7 @@ osong(void) #ifndef USE_BSMTP bbs_sendmail(filename, save_title, address); #else - bsmtp(filename, save_title, address, 0); + bsmtp(filename, save_title, address); #endif } clear(); diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 04aefeb6..eb7ce9d7 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -24,7 +24,7 @@ setforward(void) sethomepath(buf, cuser.userid); strcat(buf, "/.forward"); if ((fp = fopen(buf, "r"))) { - fscanf(fp, "%s", ip); // XXX check buffer size + fscanf(fp, "%" toSTR(sizeof(ip)) "s", ip); fclose(fp); } getdata_buf(b_lines - 1, 0, "請輸入自動轉寄的Email: ", @@ -365,7 +365,7 @@ do_send(const char *userid, const char *title) #ifndef USE_BSMTP bbs_sendmail(fpath, save_title, userid); #else - bsmtp(fpath, save_title, userid, 0); + bsmtp(fpath, save_title, userid); #endif hold_mail(fpath, userid); } @@ -1681,9 +1681,13 @@ bbs_sendmail(const char *fpath, const char *title, char *receiver) cuser.userid, str_mail_address, receiver); fin = fopen(fpath, "r"); } + if (fin == NULL) + return -1; fout = popen(genbuf, "w"); - if (fin == NULL || fout == NULL) // XXX no fclose() if only one fopen succeed + if (fout == NULL) { + fclose(fin); return -1; + } if (fpath) fprintf(fout, "Reply-To: %s%s\nFrom: %s <%s%s>\n", @@ -1711,7 +1715,7 @@ bbs_sendmail(const char *fpath, const char *title, char *receiver) #else /* USE_BSMTP */ int -bsmtp(const char *fpath, const char *title, const char *rcpt, int method) +bsmtp(const char *fpath, const char *title, const char *rcpt) { char buf[80], *ptr; time4_t chrono; @@ -1731,28 +1735,28 @@ bsmtp(const char *fpath, const char *title, const char *rcpt, int method) return send_inner_mail(fpath, title, hacker); } chrono = now; - if (method != MQ_JUSTIFY) { /* 認證信 */ - /* stamp the queue file */ - strlcpy(buf, "out/", sizeof(buf)); - for (;;) { - snprintf(buf + 4, sizeof(buf) - 4, "M.%d.A", (int)++chrono); - if (!dashf(buf)) { - Copy(fpath, buf); - break; - } + + /* stamp the queue file */ + strlcpy(buf, "out/", sizeof(buf)); + for (;;) { + snprintf(buf + 4, sizeof(buf) - 4, "M.%d.%d.A", (int)++chrono, getpid()); + if (!dashf(buf)) { + Copy(fpath, buf); + break; } + } - fpath = buf; + fpath = buf; - strlcpy(mqueue.filepath, fpath, sizeof(mqueue.filepath)); - strlcpy(mqueue.subject, title, sizeof(mqueue.subject)); - } /* setup mail queue */ mqueue.mailtime = chrono; - mqueue.method = method; + // XXX (unused) mqueue.method = method; + strlcpy(mqueue.filepath, fpath, sizeof(mqueue.filepath)); + strlcpy(mqueue.subject, title, sizeof(mqueue.subject)); strlcpy(mqueue.sender, cuser.userid, sizeof(mqueue.sender)); strlcpy(mqueue.username, cuser.nickname, sizeof(mqueue.username)); strlcpy(mqueue.rcpt, rcpt, sizeof(mqueue.rcpt)); + if (append_record("out/.DIR", (fileheader_t *) & mqueue, sizeof(mqueue)) < 0) return 0; return chrono; @@ -1840,7 +1844,7 @@ doforward(const char *direct, const fileheader_t * fh, int mode) snprintf(fname, sizeof(fname), "/tmp/bbs.f%05d", (int)currpid); snprintf(tmp_buf, sizeof(tmp_buf), "%s/%s", direct, fh->filename); - copy_file(tmp_buf, fname); + Copy(tmp_buf, fname); } else return -1; @@ -1848,7 +1852,7 @@ doforward(const char *direct, const fileheader_t * fh, int mode) #ifndef USE_BSMTP bbs_sendmail(fname, fh->title, address); #else - bsmtp(fname, fh->title, address, mode); + bsmtp(fname, fh->title, address); #endif unlink(fname); return (return_no); diff --git a/mbbsd/record.c b/mbbsd/record.c index e8b56500..dc0ed900 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -603,7 +603,7 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * #ifndef USE_BSMTP bbs_sendmail(buf, record->title, address); #else - bsmtp(buf, record->title, address, 0); + bsmtp(buf, record->title, address); #endif return 0; } diff --git a/mbbsd/register.c b/mbbsd/register.c index 55b817b6..2ec74ff6 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -231,7 +231,7 @@ new_register(void) outs("無法接受這個代號,請使用英文字母,並且不要包含空格\n"); else if ((id = getuser(passbuf, &xuser)) && (minute = check_and_expire_account(id, &xuser)) >= 0) { - if (minute == 999999) // XXX magic number + if (minute == 999999) // XXX magic number. It should be greater than MAX_USERS at least. outs("此代號已經有人使用 是不死之身"); else { prints("此代號已經有人使用 還有%d天才過期 \n", minute / (60 * 24)); diff --git a/mbbsd/user.c b/mbbsd/user.c index 716781d0..98f2052a 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -545,7 +545,7 @@ static void email_justify(const userec_t *muser) mobile_message(mobile, buf); else #endif - bsmtp("etc/registermail", buf, muser->email, 0); + bsmtp("etc/registermail", buf, muser->email); strlcpy(cuser.userid, tmp, sizeof(cuser.userid)); move(20,0); clrtobot(); |