summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-04-07 19:58:14 +0300
committerAndrei Karas <akaras@inbox.ru>2015-04-09 11:52:59 +0300
commit10685291528d1a7ba21fb99f608088f5efc9529a (patch)
treef1c87e518521670d8e1c92034b9b29d2d1014d76 /src
parent991ef8e1be441063303efde1ae4914966c1c9428 (diff)
downloadhercules-10685291528d1a7ba21fb99f608088f5efc9529a.tar.gz
hercules-10685291528d1a7ba21fb99f608088f5efc9529a.tar.bz2
hercules-10685291528d1a7ba21fb99f608088f5efc9529a.tar.xz
hercules-10685291528d1a7ba21fb99f608088f5efc9529a.zip
Add checks to ipban_sql.c
Diffstat (limited to 'src')
-rw-r--r--src/login/ipban_sql.c13
1 files changed, 9 insertions, 4 deletions
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);
+ }
}
}