diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-03-31 13:10:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-09 11:52:35 +0300 |
commit | 65ec2372eed350ba5796e9c9be0e092e5ffa4ff4 (patch) | |
tree | 5b066cbd4b674977bfc0a0165409edefbdbc13bc | |
parent | b9640535e151f7bc74f94deb72d8e544b714984e (diff) | |
download | hercules-65ec2372eed350ba5796e9c9be0e092e5ffa4ff4.tar.gz hercules-65ec2372eed350ba5796e9c9be0e092e5ffa4ff4.tar.bz2 hercules-65ec2372eed350ba5796e9c9be0e092e5ffa4ff4.tar.xz hercules-65ec2372eed350ba5796e9c9be0e092e5ffa4ff4.zip |
Add checks to pincode.c
-rw-r--r-- | src/char/pincode.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/char/pincode.c b/src/char/pincode.c index b8b30a1b8..c3d2b2298 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -11,6 +11,7 @@ #include "char.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" +#include "../common/nullpo.h" #include "../common/random.h" #include "../common/showmsg.h" #include "../common/socket.h" @@ -18,9 +19,10 @@ struct pincode_interface pincode_s; -void pincode_handle ( int fd, struct char_session_data* sd ) { +void pincode_handle (int fd, struct char_session_data* sd) { struct online_char_data* character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id); + nullpo_retv(sd); if( character && character->pincode_enable > pincode->charselect ){ character->pincode_enable = pincode->charselect * 2; }else{ @@ -44,6 +46,7 @@ void pincode_handle ( int fd, struct char_session_data* sd ) { void pincode_check(int fd, struct char_session_data* sd) { char pin[5] = "\0\0\0\0"; + nullpo_retv(sd); safestrncpy(pin, (char*)RFIFOP(fd, 6), sizeof(pin)); pincode->decrypt(sd->pincode_seed, pin); if( pincode->compare( fd, sd, pin ) ){ @@ -55,6 +58,8 @@ void pincode_check(int fd, struct char_session_data* sd) { } int pincode_compare(int fd, struct char_session_data* sd, char* pin) { + nullpo_ret(sd); + nullpo_ret(pin); if( strcmp( sd->pincode, pin ) == 0 ){ sd->pincode_try = 0; return 1; @@ -70,6 +75,7 @@ int pincode_compare(int fd, struct char_session_data* sd, char* pin) { void pincode_change(int fd, struct char_session_data* sd) { char oldpin[5] = "\0\0\0\0", newpin[5] = "\0\0\0\0"; + nullpo_retv(sd); safestrncpy(oldpin, (char*)RFIFOP(fd,6), sizeof(oldpin)); pincode->decrypt(sd->pincode_seed,oldpin); if( !pincode->compare( fd, sd, oldpin ) ) @@ -85,6 +91,7 @@ void pincode_change(int fd, struct char_session_data* sd) { void pincode_setnew(int fd, struct char_session_data* sd) { char newpin[5] = "\0\0\0\0"; + nullpo_retv(sd); safestrncpy(newpin, (char*)RFIFOP(fd,6), sizeof(newpin)); pincode->decrypt(sd->pincode_seed,newpin); pincode->update( sd->account_id, newpin ); @@ -102,6 +109,7 @@ void pincode_setnew(int fd, struct char_session_data* sd) { // 7 = char select window shows a button - client sends 0x8c5 // 8 = pincode was incorrect void pincode_sendstate(int fd, struct char_session_data* sd, uint16 state) { + nullpo_retv(sd); WFIFOHEAD(fd, 12); WFIFOW(fd, 0) = 0x8b9; WFIFOL(fd, 2) = sd->pincode_seed = rnd() % 0xFFFF; @@ -111,6 +119,8 @@ void pincode_sendstate(int fd, struct char_session_data* sd, uint16 state) { } void pincode_notifyLoginPinUpdate(int account_id, char* pin) { + nullpo_retv(pin); + Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,11); WFIFOW(chr->login_fd,0) = 0x2738; WFIFOL(chr->login_fd,2) = account_id; @@ -129,6 +139,7 @@ void pincode_decrypt(unsigned int userSeed, char* pin) { int i; char tab[10] = {0,1,2,3,4,5,6,7,8,9}; + nullpo_retv(pin); for (i = 1; i < 10; i++) { int pos; userSeed = pincode->baseSeed + userSeed * pincode->multiplier; @@ -149,6 +160,8 @@ void pincode_decrypt(unsigned int userSeed, char* pin) { bool pincode_config_read(char *w1, char *w2) { + nullpo_ret(w1); + nullpo_ret(w2); while ( true ) { if ( strcmpi(w1, "pincode_enabled") == 0 ) { pincode->enabled = atoi(w2); |