summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/inter.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/char/inter.c b/src/char/inter.c
index eb14f1593..ec06df0f9 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -27,6 +27,7 @@
#include "../common/db.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
+#include "../common/nullpo.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/strlib.h"
@@ -97,6 +98,7 @@ bool inter_msg_config_read(const char *cfg_name, bool allow_override)
FILE *fp;
static int called = 1;
+ nullpo_ret(cfg_name);
if ((fp = fopen(cfg_name, "r")) == NULL) {
ShowError("Messages file not found: %s\n", cfg_name);
return 1;
@@ -384,6 +386,7 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap)
va_list apcopy;
int len = 1;/* yes we start at 1 */
+ nullpo_retv(msg);
va_copy(apcopy, ap);
len += vsnprintf(msg_out, 512, msg, apcopy);
va_end(apcopy);
@@ -484,6 +487,12 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate,
int group_id, int logincount, int state)
{
+ nullpo_retv(userid);
+ nullpo_retv(user_pass);
+ nullpo_retv(email);
+ nullpo_retv(last_ip);
+ nullpo_retv(lastlogin);
+ nullpo_retv(birthdate);
if (map_fd <= 0 || !session_isActive(map_fd))
return; // check if we have a valid fd
@@ -546,6 +555,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
**/
void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string)
{
+ nullpo_retv(key);
/* to login server we go! */
if( key[0] == '#' && key[1] == '#' ) {/* global account reg */
if( session_isValid(chr->login_fd) )
@@ -769,6 +779,7 @@ static int inter_config_read(const char* cfgName)
char line[1024], w1[1024], w2[1024];
FILE* fp;
+ nullpo_retr(1, cfgName);
fp = fopen(cfgName, "r");
if(fp == NULL) {
ShowError("File not found: %s\n", cfgName);
@@ -916,6 +927,8 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short f
{
unsigned char *buf = (unsigned char*)aMalloc((len)*sizeof(unsigned char));
+ nullpo_ret(mes);
+ Assert_ret(len >= 16);
WBUFW(buf,0) = 0x3800;
WBUFW(buf,2) = len;
WBUFL(buf,4) = fontColor;
@@ -934,8 +947,12 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned int fontColor, short f
int mapif_wis_message(struct WisData *wd)
{
unsigned char buf[2048];
+ nullpo_ret(wd);
//if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex]
- if( wd->len >= sizeof(wd->msg) - 1 ) wd->len = sizeof(wd->msg) - 1;
+ if (wd->len < 0)
+ wd->len = 0;
+ if (wd->len >= sizeof(wd->msg) - 1)
+ wd->len = sizeof(wd->msg) - 1;
WBUFW(buf, 0) = 0x3801;
WBUFW(buf, 2) = 56 +wd->len;
@@ -951,6 +968,7 @@ int mapif_wis_message(struct WisData *wd)
void mapif_wis_response(int fd, unsigned char *src, int flag)
{
unsigned char buf[27];
+ nullpo_retv(src);
WBUFW(buf, 0)=0x3802;
memcpy(WBUFP(buf, 2),src,24);
WBUFB(buf,26)=flag;
@@ -960,6 +978,7 @@ void mapif_wis_response(int fd, unsigned char *src, int flag)
// Wis sending result
int mapif_wis_end(struct WisData *wd, int flag)
{
+ nullpo_ret(wd);
mapif->wis_response(wd->fd, wd->src, flag);
return 0;
}
@@ -968,6 +987,7 @@ int mapif_wis_end(struct WisData *wd, int flag)
// Account registry transfer to map-server
static void mapif_account_reg(int fd, unsigned char *src)
{
+ nullpo_retv(src);
WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
mapif->sendallwos(fd, src, WBUFW(src,2));
}
@@ -1005,6 +1025,7 @@ int inter_check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
{
int64 tick;
struct WisData *wd = DB->data2ptr(data);
+ nullpo_ret(wd);
tick = va_arg(ap, int64);
if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
@@ -1208,6 +1229,7 @@ int mapif_parse_RegistryRequest(int fd)
void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *const name)
{
+ nullpo_retv(name);
WFIFOHEAD(fd, NAME_LENGTH+13);
WFIFOW(fd, 0) = 0x3806;
WFIFOL(fd, 2) = account_id;