From 10685291528d1a7ba21fb99f608088f5efc9529a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 7 Apr 2015 19:58:14 +0300 Subject: Add checks to ipban_sql.c --- src/login/ipban_sql.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index bfc90ad11..f995450ce 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -14,6 +14,7 @@ #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" +#include "../common/nullpo.h" #include "../common/sql.h" #include "../common/socket.h" #include "../common/strlib.h" @@ -118,6 +119,8 @@ bool ipban_config_read(const char* key, const char* value) { const char* signature; + nullpo_ret(key); + nullpo_ret(value); if( ipban_inited ) return false;// settings can only be changed before init @@ -220,8 +223,8 @@ bool ipban_check(uint32 ip) return true; } - if( SQL_ERROR == SQL->NextRow(sql_handle) ) - return true;// Shouldn't happen, but just in case... + if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) + return false; SQL->GetData(sql_handle, 0, &data, NULL); matches = atoi(data); @@ -244,9 +247,11 @@ void ipban_log(uint32 ip) if( failures >= login_config.dynamic_pass_failure_ban_limit ) { uint8* p = (uint8*)&ip; - if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')", - ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration) ) + if (SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')", + ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration)) + { Sql_ShowDebug(sql_handle); + } } } -- cgit v1.2.3-60-g2f50