From 54482f9e30665501bf7318919e3aaf0993b36b9b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 Mar 2015 00:36:34 +0300 Subject: Add checks to int_mail.c --- src/char/int_mail.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/char/int_mail.c') diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 17fb9d424..cd2fa0deb 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -15,6 +15,7 @@ #include "mapif.h" #include "../common/malloc.h" #include "../common/mmo.h" +#include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/socket.h" #include "../common/sql.h" @@ -30,6 +31,7 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md) char *data; StringBuf buf; + nullpo_ret(md); memset(md, 0, sizeof(struct mail_data)); md->amount = 0; md->full = false; @@ -114,6 +116,7 @@ int inter_mail_savemessage(struct mail_message* msg) SqlStmt* stmt; int j; + nullpo_ret(msg); // build message save query StrBuf->Init(&buf); StrBuf->Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`, `unique_id`", mail_db); @@ -151,6 +154,7 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg) { int j; StringBuf buf; + nullpo_ret(msg); memset(msg, 0, sizeof(struct mail_message)); // Initialize data StrBuf->Init(&buf); @@ -203,6 +207,7 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg) void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md) { + nullpo_retv(md); //FIXME: dumping the whole structure like this is unsafe [ultramage] WFIFOHEAD(fd, sizeof(struct mail_data) + 9); WFIFOW(fd,0) = 0x3848; @@ -263,6 +268,7 @@ static bool inter_mail_DeleteAttach(int mail_id) void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg) { + nullpo_retv(msg); WFIFOHEAD(fd, sizeof(struct item) + 12); WFIFOW(fd,0) = 0x384a; WFIFOW(fd,2) = sizeof(struct item) + 12; @@ -402,6 +408,7 @@ void mapif_mail_send(int fd, struct mail_message* msg) { int len = sizeof(struct mail_message) + 4; + nullpo_retv(msg); WFIFOHEAD(fd,len); WFIFOW(fd,0) = 0x384d; WFIFOW(fd,2) = len; @@ -449,6 +456,11 @@ void mapif_parse_mail_send(int fd) void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item) { struct mail_message msg; + nullpo_retv(send_name); + nullpo_retv(dest_name); + nullpo_retv(title); + nullpo_retv(body); + nullpo_retv(item); memset(&msg, 0, sizeof(struct mail_message)); msg.send_id = send_id; -- cgit v1.2.3-60-g2f50