void write_to_file(void *buf, int size, long filepos) { FILE *mail_file; mail_file = fopen(MAIL_FILE, "r+b"); if (filepos % BLOCK_SIZE) { log("SYSERR: Mail system -- fatal error #2!!!"); no_mail = 1; return; } If there does happen to be an invalid filepos % BLOCKSIZE then the opened MAIL_FILE is not closed. The function also does not check to make sure it succeeded in opening the file. diff -up ../stk/mail.c ./mail.c --- ../stk/mail.c Thu Jun 19 00:58:37 1997 +++ ./mail.c Sun Jul 13 20:50:25 1997 @@ -90,13 +90,16 @@ void write_to_file(void *buf, int size, { FILE *mail_file; - mail_file = fopen(MAIL_FILE, "r+b"); - if (filepos % BLOCK_SIZE) { log("SYSERR: Mail system -- fatal error #2!!!"); no_mail = 1; return; } + if (!(mail_file = fopen(MAIL_FILE, "r+b"))) { + log("SYSERR: Unable to open mail file."); + no_mail = 1; + return; + } fseek(mail_file, filepos, SEEK_SET); fwrite(buf, size, 1, mail_file); @@ -112,13 +115,17 @@ void read_from_file(void *buf, int size, { FILE *mail_file; - mail_file = fopen(MAIL_FILE, "r+b"); - if (filepos % BLOCK_SIZE) { log("SYSERR: Mail system -- fatal error #3!!!"); no_mail = 1; return; } + if (!(mail_file = fopen(MAIL_FILE, "r+b"))) { + log("SYSERR: Unable to open mail file."); + no_mail = 1; + return; + } + fseek(mail_file, filepos, SEEK_SET); fread(buf, size, 1, mail_file); fclose(mail_file); -George +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list-faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST