diff options
author | Guilherme G. Menaldo <guilherme.menaldo@outlook.com> | 2018-03-01 02:12:57 -0300 |
---|---|---|
committer | Guilherme G. Menaldo <guilherme.menaldo@outlook.com> | 2018-03-08 23:14:22 -0300 |
commit | c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24 (patch) | |
tree | 6f19b0e13e7046599f0b54dd23715020d21119ce /src/char | |
parent | 5b4f79ade2152da83e3c5df610efd54714acaa1f (diff) | |
download | hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.gz hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.bz2 hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.xz hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.zip |
Fixed a nullpo error when user tried to do an action in an unloaded mail in rodex
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/int_rodex.c | 14 | ||||
-rw-r--r-- | src/char/mapif.c | 2 | ||||
-rw-r--r-- | src/char/mapif.h | 2 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c index 127f7a213..2001ddc43 100644 --- a/src/char/int_rodex.c +++ b/src/char/int_rodex.c @@ -349,22 +349,23 @@ int64 inter_rodex_savemessage(struct rodex_message* msg) /*========================================== * Inbox Request *------------------------------------------*/ -void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails) +void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) { - int per_packet = (UINT16_MAX - 16) / sizeof(struct rodex_message); + int per_packet = (UINT16_MAX - 24) / sizeof(struct rodex_message); int sent = 0; bool is_first = true; nullpo_retv(mails); Assert_retv(char_id > 0); Assert_retv(count >= 0); + Assert_retv(mail_id >= 0); do { - int i = 16, j, size, limit; + int i = 24, j, size, limit; int to_send = count - sent; bool is_last = true; if (to_send <= per_packet) { - size = to_send * sizeof(struct rodex_message) + 16; + size = to_send * sizeof(struct rodex_message) + 24; limit = to_send; is_last = true; } else { @@ -372,7 +373,7 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co if (limit != to_send) { is_last = false; } - size = limit * sizeof(struct rodex_message) + 16; + size = limit * sizeof(struct rodex_message) + 24; } WFIFOHEAD(fd, size); @@ -384,6 +385,7 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co WFIFOB(fd, 10) = is_last; WFIFOB(fd, 11) = is_first; WFIFOL(fd, 12) = limit; + WFIFOQ(fd, 16) = mail_id; for (j = 0; j < limit; ++j, ++sent, i += sizeof(struct rodex_message)) { memcpy(WFIFOP(fd, i), &VECTOR_INDEX(*mails, sent), sizeof(struct rodex_message)); } @@ -408,7 +410,7 @@ void mapif_parse_rodex_requestinbox(int fd) count = inter_rodex->fromsql(char_id, account_id, opentype, 0, &mails); else count = inter_rodex->fromsql(char_id, account_id, opentype, mail_id, &mails); - mapif->rodex_sendinbox(fd, char_id, opentype, flag, count, &mails); + mapif->rodex_sendinbox(fd, char_id, opentype, flag, count, mail_id, &mails); VECTOR_CLEAR(mails); } diff --git a/src/char/mapif.c b/src/char/mapif.c index 241edc925..f80e38fe7 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -185,7 +185,7 @@ void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_ int mapif_parse_quest_load(int fd); /* RoDEX */ int mapif_parse_rodex_requestinbox(int fd); -void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails); +void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails); int mapif_parse_rodex_checkhasnew(int fd); void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new); int mapif_parse_rodex_updatemail(int fd); diff --git a/src/char/mapif.h b/src/char/mapif.h index f03f1ad9a..7fc79f661 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -177,7 +177,7 @@ struct mapif_interface { void (*send_quests) (int fd, int char_id, struct quest *tmp_questlog, int num_quests); int (*parse_quest_load) (int fd); int(*parse_rodex_requestinbox) (int fd); - void(*rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, struct rodex_maillist *mails); + void(*rodex_sendinbox) (int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails); int(*parse_rodex_checkhasnew) (int fd); void(*rodex_sendhasnew) (int fd, int char_id, bool has_new); int(*parse_rodex_updatemail) (int fd); |