memory alloc/free updates
This commit is contained in:
parent
0a1e075744
commit
c894d863ed
35 changed files with 306 additions and 286 deletions
|
@ -4,6 +4,7 @@ Anything we add/remove/fix/change is in here (even our rants)
|
|||
Fish (F), Mark (M)
|
||||
===============================================================================
|
||||
* NeoStats * Version 3.0.genesis
|
||||
- New memory allocation wrappers functions scalloc, srealloc and sfree.
|
||||
- Add SET VERSIONSCAN option to core for CTCP version scanning.
|
||||
- StatServ: Optimise database save to further reduce code required and get
|
||||
back a little CPU.
|
||||
|
|
12
src/bans.c
12
src/bans.c
|
@ -74,8 +74,8 @@ void AddBan(const char* type, const char* user, const char* host, const char* ma
|
|||
AddStringToList (&cmdparams->av, (char*)tsset, &cmdparams->ac);
|
||||
AddStringToList (&cmdparams->av, (char*)tsexpires, &cmdparams->ac);
|
||||
SendAllModuleEvent (EVENT_ADDBAN, cmdparams);
|
||||
free (cmdparams->av);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams->av);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -104,12 +104,12 @@ DelBan(const char* type, const char* user, const char* host, const char* mask,
|
|||
AddStringToList (&cmdparams->av, (char*)tsset, &cmdparams->ac);
|
||||
AddStringToList (&cmdparams->av, (char*)tsexpires, &cmdparams->ac);
|
||||
SendAllModuleEvent (EVENT_DELBAN, cmdparams);
|
||||
free (cmdparams->av);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams->av);
|
||||
sfree (cmdparams);
|
||||
|
||||
hash_delete (banshash, bansnode);
|
||||
hnode_destroy (bansnode);
|
||||
free (ban);
|
||||
sfree (ban);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -139,7 +139,7 @@ void FiniBans (void)
|
|||
ban = hnode_get (bansnode);
|
||||
hash_delete (banshash, bansnode);
|
||||
hnode_destroy (bansnode);
|
||||
free (ban);
|
||||
sfree (ban);
|
||||
}
|
||||
hash_destroy(banshash);
|
||||
}
|
||||
|
|
18
src/bots.c
18
src/bots.c
|
@ -83,7 +83,7 @@ add_chan_bot (char *bot, char *chan)
|
|||
|
||||
cbn = hash_lookup (bch, chan);
|
||||
if (!cbn) {
|
||||
mod_chan_bot = malloc (sizeof (ChanBot));
|
||||
mod_chan_bot = smalloc (sizeof (ChanBot));
|
||||
strlcpy (mod_chan_bot->chan, chan, CHANLEN);
|
||||
mod_chan_bot->bots = list_create (B_TABLE_SIZE);
|
||||
cbn = hnode_create (mod_chan_bot);
|
||||
|
@ -139,7 +139,7 @@ del_chan_bot (char *bot, char *chan)
|
|||
/* delete the hash and list because its all over */
|
||||
hash_delete (bch, cbn);
|
||||
list_destroy (mod_chan_bot->bots);
|
||||
free (mod_chan_bot->chan);
|
||||
sfree (mod_chan_bot->chan);
|
||||
hnode_destroy (cbn);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void bot_notice (char *origin, char **av, int ac)
|
|||
cmdparams->param += 9;
|
||||
SendModuleEvent (EVENT_CTCPVERSION, cmdparams, NULL);
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void bot_chan_notice (char *origin, char **av, int ac)
|
|||
}
|
||||
}
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
/** @brief send a message to a bot
|
||||
|
@ -290,7 +290,7 @@ void bot_private (char *origin, char **av, int ac)
|
|||
cmdparams->param = av[ac - 1];
|
||||
if ((cmdparams->dest.bot->flags & BOT_FLAG_SERVICEBOT)) {
|
||||
if(run_bot_cmd (cmdparams) != NS_FAILURE) {
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ void bot_private (char *origin, char **av, int ac)
|
|||
}
|
||||
}
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
/** @brief send a message to a bot
|
||||
|
@ -326,7 +326,7 @@ void bot_chan_private (char *origin, char **av, int ac)
|
|||
}
|
||||
}
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
/** @brief create a new bot
|
||||
|
@ -343,7 +343,7 @@ new_bot (char *bot_name)
|
|||
|
||||
SET_SEGV_LOCATION();
|
||||
nlog (LOG_DEBUG2, "new_bot: %s", bot_name);
|
||||
botptr = malloc (sizeof (Bot));
|
||||
botptr = smalloc (sizeof (Bot));
|
||||
strlcpy (botptr->nick, bot_name, MAXNICK);
|
||||
bn = hnode_create (botptr);
|
||||
if (hash_isfull (bh)) {
|
||||
|
@ -417,7 +417,7 @@ del_ns_bot (char *bot_name)
|
|||
botptr = hnode_get (bn);
|
||||
del_all_bot_cmds(botptr);
|
||||
hnode_destroy (bn);
|
||||
free (botptr);
|
||||
sfree (botptr);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_FAILURE;
|
||||
|
|
|
@ -126,8 +126,8 @@ ChanTopic (const char* chan, const char *owner, const char* ts, const char *topi
|
|||
AddStringToList (&cmdparams->av, "", &cmdparams->ac);
|
||||
}
|
||||
SendAllModuleEvent (EVENT_TOPIC, cmdparams);
|
||||
free (cmdparams->av);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams->av);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
/** @brief Check if a mode is set on a Channel
|
||||
|
@ -223,7 +223,7 @@ ChanMode (char *origin, char **av, int ac)
|
|||
AddStringToList(&cmdparams->av, av[i], &cmdparams->ac);
|
||||
}
|
||||
SendAllModuleEvent(EVENT_CHANMODE, cmdparams);
|
||||
free(cmdparams);
|
||||
sfree(cmdparams);
|
||||
|
||||
modes = av[1];
|
||||
while (*modes) {
|
||||
|
@ -297,7 +297,7 @@ ChanMode (char *origin, char **av, int ac)
|
|||
list_delete (c->modeparms, mn);
|
||||
m = lnode_get (mn);
|
||||
lnode_destroy (mn);
|
||||
free (m);
|
||||
sfree (m);
|
||||
|
||||
if (!(chan_modes[i].mode == CMODE_LIMIT))
|
||||
j++;
|
||||
|
@ -383,12 +383,12 @@ new_chan (const char *chan)
|
|||
hnode_t *cn;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
c = calloc (sizeof (Channel), 1);
|
||||
c = scalloc (sizeof (Channel));
|
||||
strlcpy (c->name, chan, CHANLEN);
|
||||
cn = hnode_create (c);
|
||||
if (hash_isfull (ch)) {
|
||||
nlog (LOG_CRITICAL, "new_chan: channel hash is full");
|
||||
free (c);
|
||||
sfree (c);
|
||||
return NULL;
|
||||
}
|
||||
hash_insert (ch, cn, c->name);
|
||||
|
@ -404,7 +404,7 @@ new_chan (const char *chan)
|
|||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->channel = c;
|
||||
SendAllModuleEvent (EVENT_NEWCHAN, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -434,11 +434,11 @@ del_chan (Channel * c)
|
|||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->channel = c;
|
||||
SendAllModuleEvent (EVENT_DELCHAN, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
|
||||
cm = list_first (c->modeparms);
|
||||
while (cm) {
|
||||
free (lnode_get (cm));
|
||||
sfree (lnode_get (cm));
|
||||
cm = list_next (c->modeparms, cm);
|
||||
}
|
||||
list_destroy_nodes (c->modeparms);
|
||||
|
@ -446,7 +446,7 @@ del_chan (Channel * c)
|
|||
list_destroy (c->chanmembers);
|
||||
hash_delete (ch, cn);
|
||||
hnode_destroy (cn);
|
||||
free (c);
|
||||
sfree (c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ kick_chan (const char *kickby, const char *chan, const char *kicked, const char
|
|||
CmdParams * cmdparams;
|
||||
cm = lnode_get (un);
|
||||
lnode_destroy (list_delete (c->chanmembers, un));
|
||||
free (cm);
|
||||
sfree (cm);
|
||||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->dest.user = u;
|
||||
cmdparams->channel = c;
|
||||
|
@ -539,7 +539,7 @@ kick_chan (const char *kickby, const char *chan, const char *kicked, const char
|
|||
del_chan_bot (u->nick, c->name);
|
||||
SendModuleEvent (EVENT_KICKBOT, cmdparams, findbot(u->nick));
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
c->users--;
|
||||
}
|
||||
del_chan_user(c, u);
|
||||
|
@ -593,7 +593,7 @@ part_chan (User * u, const char *chan, const char *reason)
|
|||
CmdParams * cmdparams;
|
||||
cm = lnode_get (un);
|
||||
lnode_destroy (list_delete (c->chanmembers, un));
|
||||
free (cm);
|
||||
sfree (cm);
|
||||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->channel = c;
|
||||
cmdparams->source.user = u;
|
||||
|
@ -606,7 +606,7 @@ part_chan (User * u, const char *chan, const char *reason)
|
|||
del_chan_bot (u->nick, c->name);
|
||||
SendModuleEvent (EVENT_PARTBOT, cmdparams, findbot(u->nick));
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
c->users--;
|
||||
}
|
||||
del_chan_user(c, u);
|
||||
|
@ -708,7 +708,7 @@ join_chan (const char* nick, const char *chan)
|
|||
if (list_isfull (c->chanmembers)) {
|
||||
nlog (LOG_CRITICAL, "join_chan: channel %s member list is full", c->name);
|
||||
lnode_destroy (cn);
|
||||
free (cm);
|
||||
sfree (cm);
|
||||
return;
|
||||
}
|
||||
list_append (c->chanmembers, cn);
|
||||
|
@ -724,7 +724,7 @@ join_chan (const char* nick, const char *chan)
|
|||
cmdparams->source.user = u;
|
||||
cmdparams->channel = c;
|
||||
SendAllModuleEvent (EVENT_JOIN, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
nlog (LOG_DEBUG3, "join_chan: cur users %s %ld (list %d)", c->name, c->users, (int)list_count (c->chanmembers));
|
||||
if ( IsMe (u) ) {
|
||||
nlog(LOG_DEBUG3, "join_chan: joining bot %s to channel %s", u->nick, c->name);
|
||||
|
|
|
@ -446,8 +446,8 @@ run_bot_cmd (CmdParams * cmdparams)
|
|||
if (( (cmdparams->dest.bot->flags & BOT_FLAG_RESTRICT_OPERS) && (userlevel < NS_ULEVEL_OPER) ) ||
|
||||
( (cmdparams->dest.bot->flags & BOT_FLAG_ONLY_OPERS) && me.onlyopers && (userlevel < NS_ULEVEL_OPER) )){
|
||||
msg_only_opers (cmdparams);
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
if(cmdparams->dest.bot->botcmds) {
|
||||
|
@ -459,15 +459,15 @@ run_bot_cmd (CmdParams * cmdparams)
|
|||
/* Is user authorised to issue this command? */
|
||||
if (userlevel < cmdlevel) {
|
||||
msg_permission_denied(cmdparams, NULL);
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
/* Check parameter count */
|
||||
if(cmdparams->ac < cmd_ptr->minparams ) {
|
||||
msg_error_need_more_params(cmdparams);
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
/* Seems OK so report the command call so modules do not have to */
|
||||
|
@ -494,20 +494,20 @@ run_bot_cmd (CmdParams * cmdparams)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
}
|
||||
if(run_intrinsic_cmds (av[0], cmdparams) == NS_SUCCESS) {
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
/* We have run out of commands so report failure */
|
||||
msg_unknown_command (cmdparams);
|
||||
free (av);
|
||||
free (cmdparams->av);
|
||||
sfree (av);
|
||||
sfree (cmdparams->av);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ bot_cmd_set_msg (CmdParams * cmdparams, bot_setting* set_ptr)
|
|||
strlcpy((char*)set_ptr->varptr, buf, set_ptr->max);
|
||||
SetConf((void *)buf, CFGSTR, set_ptr->confitem);
|
||||
bot_cmd_set_report (cmdparams, set_ptr, buf);
|
||||
free(buf);
|
||||
sfree(buf);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -893,7 +893,7 @@ bot_cmd_set_realname (CmdParams * cmdparams, bot_setting* set_ptr)
|
|||
strlcpy((char*)set_ptr->varptr, buf, set_ptr->max);
|
||||
SetConf((void *)buf, CFGSTR, set_ptr->confitem);
|
||||
bot_cmd_set_report (cmdparams, set_ptr, buf);
|
||||
free(buf);
|
||||
sfree(buf);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ ConfLoadModules ()
|
|||
} else {
|
||||
nlog (LOG_WARNING, "Could Not Load Module %s, Please check above error Messages", (char *)load_mods[i]);
|
||||
}
|
||||
free(load_mods[i]);
|
||||
sfree(load_mods[i]);
|
||||
}
|
||||
nlog (LOG_NORMAL, "Completed loading configured modules");
|
||||
return NS_SUCCESS;
|
||||
|
|
26
src/dns.c
26
src/dns.c
|
@ -90,7 +90,7 @@ int dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_
|
|||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
dnsdata = malloc (sizeof (DnsLookup));
|
||||
dnsdata = smalloc (sizeof (DnsLookup));
|
||||
DNSStats.totalq++;
|
||||
if (!dnsdata) {
|
||||
nlog (LOG_CRITICAL, "DNS: Out of Memory");
|
||||
|
@ -125,7 +125,7 @@ int dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_
|
|||
}
|
||||
if (status) {
|
||||
nlog (LOG_WARNING, "DNS: adns_submit error: %s", strerror (status));
|
||||
free (dnsdata);
|
||||
sfree (dnsdata);
|
||||
DNSStats.failure++;
|
||||
return 0;
|
||||
}
|
||||
|
@ -184,14 +184,14 @@ void FiniDns (void)
|
|||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
adns_cancel(dnsdata->q);
|
||||
free (dnsdata->a);
|
||||
free (dnsdata);
|
||||
sfree (dnsdata->a);
|
||||
sfree (dnsdata);
|
||||
}
|
||||
list_destroy_nodes(dnslist);
|
||||
dnsnode = list_first(dnsqueue);
|
||||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
free(dnsdata);
|
||||
sfree(dnsdata);
|
||||
}
|
||||
list_destroy_nodes(dnsqueue);
|
||||
free(ads);
|
||||
|
@ -212,8 +212,8 @@ void canx_dns(Module* modptr)
|
|||
dnsdata = lnode_get(dnsnode);
|
||||
if (dnsdata->modptr == modptr) {
|
||||
adns_cancel(dnsdata->q);
|
||||
free (dnsdata->a);
|
||||
free (dnsdata);
|
||||
sfree (dnsdata->a);
|
||||
sfree (dnsdata);
|
||||
lnode2 = list_next(dnslist, dnsnode);
|
||||
list_delete(dnslist, dnsnode);
|
||||
lnode_destroy(dnsnode);
|
||||
|
@ -224,7 +224,7 @@ void canx_dns(Module* modptr)
|
|||
while (dnsnode) {
|
||||
dnsdata = lnode_get(dnsnode);
|
||||
if (dnsdata->modptr == modptr) {
|
||||
free(dnsdata);
|
||||
sfree(dnsdata);
|
||||
lnode2 = list_next(dnsqueue, dnsnode);
|
||||
list_delete(dnsqueue, dnsnode);
|
||||
lnode_destroy(dnsnode);
|
||||
|
@ -279,8 +279,8 @@ void do_dns (void)
|
|||
/* delete from list */
|
||||
dnsnode1 = list_delete (dnslist, dnsnode);
|
||||
dnsnode = list_next (dnslist, dnsnode1);
|
||||
free (dnsdata->a);
|
||||
free (dnsdata);
|
||||
sfree (dnsdata->a);
|
||||
sfree (dnsdata);
|
||||
lnode_destroy (dnsnode1);
|
||||
break;
|
||||
}
|
||||
|
@ -293,8 +293,8 @@ void do_dns (void)
|
|||
/* delete from list */
|
||||
dnsnode1 = list_delete (dnslist, dnsnode);
|
||||
dnsnode = list_next (dnslist, dnsnode1);
|
||||
free (dnsdata->a);
|
||||
free (dnsdata);
|
||||
sfree (dnsdata->a);
|
||||
sfree (dnsdata);
|
||||
lnode_destroy (dnsnode1);
|
||||
}
|
||||
dns_check_queue();
|
||||
|
@ -329,7 +329,7 @@ void dns_check_queue() {
|
|||
if (status) {
|
||||
/* delete from queue and delete node */
|
||||
nlog (LOG_WARNING, "DNS: adns_submit error: %s", strerror (status));
|
||||
free (dnsdata);
|
||||
sfree (dnsdata);
|
||||
dnsnode2 = dnsnode;
|
||||
dnsnode = list_next(dnsqueue, dnsnode);
|
||||
list_delete(dnsqueue, dnsnode2);
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
**
|
||||
** Portions Copyright (c) 2000-2001 ^Enigma^
|
||||
**
|
||||
** Based on dotconf
|
||||
** Copyright (C) 1999 Lukas Schröder
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
|
@ -22,24 +25,6 @@
|
|||
** Code portions Borrowed from the dotconf libary. Header follows:
|
||||
*/
|
||||
|
||||
/* dotconf
|
||||
* Copyright (C) 1999 Lukas Schröder
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
/*
|
||||
** NeoStats CVS Identification
|
||||
** $Id$
|
||||
|
@ -54,7 +39,6 @@
|
|||
#include "neostats.h"
|
||||
#include "dotconf.h"
|
||||
#include "support.h"
|
||||
#include "ircstring.h"
|
||||
static int word_count; /* no. of option arguments */
|
||||
static char name[CFG_MAX_OPTION + 1]; /* option name */
|
||||
static char values[CFG_VALUES][CFG_MAX_VALUE + 1]; /* holds the arguments */
|
||||
|
@ -77,9 +61,10 @@ static config_option *config_options[CFG_MODULES];
|
|||
static void dotconf_cb_include (char *); /* magic 'Include' */
|
||||
static void dotconf_cb_includepath (char *); /* magic 'IncludePath' */
|
||||
|
||||
static config_option dotconf_options[] = { {"Include", ARG_STR, dotconf_cb_include, 0},
|
||||
{"IncludePath", ARG_STR, dotconf_cb_includepath, 0},
|
||||
LAST_OPTION
|
||||
static config_option dotconf_options[] = {
|
||||
{"Include", ARG_STR, dotconf_cb_include, 0},
|
||||
{"IncludePath", ARG_STR, dotconf_cb_includepath, 0},
|
||||
LAST_OPTION
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -235,8 +220,7 @@ config_parse (FILE * config)
|
|||
* allocate a buffer of filesize bytes; should be enough to
|
||||
* prevent buffer overflows
|
||||
*/
|
||||
here_doc = malloc (finfo.st_size + 1); /* allocate buffer memory */
|
||||
bzero (here_doc, finfo.st_size + 1);
|
||||
here_doc = scalloc (finfo.st_size + 1); /* allocate buffer memory */
|
||||
|
||||
strlcpy (here_limit, cp3 + 2, 8); /* copy here-delimiter */
|
||||
while (fgets (buffer, CFG_BUFSIZE, config)) {
|
||||
|
@ -251,14 +235,13 @@ config_parse (FILE * config)
|
|||
here_doc[strlen (here_doc) - 1] = '\0'; /* strip newline */
|
||||
opt.callback (here_doc, opt.userdata); /* call back */
|
||||
|
||||
free (here_doc); /* free buffer memory */
|
||||
sfree (here_doc); /* free buffer memory */
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free (here_doc);
|
||||
/* skip whitespace */
|
||||
while ((cp1 < eob) && (*cp1 != '\0') && (isspace (*cp1)))
|
||||
cp1++;
|
||||
|
@ -352,7 +335,7 @@ config_parse (FILE * config)
|
|||
opt.callback (data, word_count, USER_DATA);
|
||||
|
||||
for (i = 0; i < word_count; i++) /* dump list */
|
||||
free (data[i]);
|
||||
sfree (data[i]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -387,8 +370,7 @@ config_read (char *fname, config_option * options)
|
|||
return 1;
|
||||
}
|
||||
|
||||
dotconf_file = malloc (CFG_MAX_FILENAME + 1); /* allocate fname buffer */
|
||||
bzero (dotconf_file, CFG_MAX_FILENAME + 1);
|
||||
dotconf_file = scalloc (CFG_MAX_FILENAME + 1); /* allocate fname buffer */
|
||||
bzero (dotconf_includepath, CFG_MAX_FILENAME + 1);
|
||||
|
||||
strlcpy (dotconf_file, fname, CFG_MAX_FILENAME); /* fill fname buffer */
|
||||
|
@ -404,7 +386,7 @@ config_read (char *fname, config_option * options)
|
|||
config_parse (config); /* fire off parser */
|
||||
fclose (config);
|
||||
|
||||
free (dotconf_file); /* free fname buffer */
|
||||
sfree (dotconf_file); /* free fname buffer */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "neostats.h"
|
||||
#include "exclude.h"
|
||||
#include "conf.h"
|
||||
#include "ircstring.h"
|
||||
#include "services.h"
|
||||
|
||||
list_t *exclude_list;
|
||||
|
@ -76,8 +75,8 @@ int InitExcludes(void)
|
|||
en = lnode_create(e);
|
||||
list_append(exclude_list, en);
|
||||
}
|
||||
free(row);
|
||||
}
|
||||
free(row);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -96,13 +95,13 @@ void ns_do_exclude_add(User *u, char *type, char *pattern) {
|
|||
char tmp[BUFSIZE];
|
||||
|
||||
/* we dont do any checking to see if a similar entry already exists... oh well, thats upto the user */
|
||||
e = malloc(sizeof(excludes));
|
||||
e = smalloc(sizeof(excludes));
|
||||
strlcpy(e->addedby, u->nick, MAXNICK);
|
||||
e->addedon = me.now;
|
||||
if (!ircstrcasecmp("HOST", type)) {
|
||||
if (!index(pattern, '.')) {
|
||||
prefmsg(u->nick, ns_botptr->nick, "Error, Pattern must contain at least one \2.\2");
|
||||
free(e);
|
||||
sfree(e);
|
||||
return;
|
||||
}
|
||||
e->type = NS_EXCLUDE_HOST;
|
||||
|
@ -110,7 +109,7 @@ void ns_do_exclude_add(User *u, char *type, char *pattern) {
|
|||
} else if (!ircstrcasecmp("CHAN", type)) {
|
||||
if (pattern[0] != '#') {
|
||||
prefmsg(u->nick, ns_botptr->nick, "Error, Pattern must begin with a \2#\2");
|
||||
free(e);
|
||||
sfree(e);
|
||||
return;
|
||||
}
|
||||
e->type = NS_EXCLUDE_CHAN;
|
||||
|
@ -118,14 +117,14 @@ void ns_do_exclude_add(User *u, char *type, char *pattern) {
|
|||
} else if (!ircstrcasecmp("SERVER", type)) {
|
||||
if (!index(pattern, '.')) {
|
||||
prefmsg(u->nick, ns_botptr->nick, "Error, Pattern must contain at least one \2.\2");
|
||||
free(e);
|
||||
sfree(e);
|
||||
return;
|
||||
}
|
||||
e->type = NS_EXCLUDE_SERVER;
|
||||
strlcpy(e->pattern, collapse(pattern), MAXHOST);
|
||||
} else {
|
||||
prefmsg(u->nick, ns_botptr->nick, "Error, Unknown type %s", type);
|
||||
free(e);
|
||||
sfree(e);
|
||||
return;
|
||||
}
|
||||
/* if we get here, then e is valid */
|
||||
|
@ -166,7 +165,7 @@ void ns_do_exclude_del(User *u, char *position) {
|
|||
ircsnprintf(tmp, BUFSIZE, "%d", (int)e->addedon);
|
||||
DelRow("Exclusions", tmp);
|
||||
prefmsg(u->nick, ns_botptr->nick, "Deleted %s out of Exclusion List", e->pattern);
|
||||
free(e);
|
||||
sfree(e);
|
||||
list_delete(exclude_list, en);
|
||||
lnode_destroy(en);
|
||||
return;
|
||||
|
|
23
src/hash.c
23
src/hash.c
|
@ -51,7 +51,6 @@
|
|||
#define HASH_IMPLEMENTATION
|
||||
#include "hash.h"
|
||||
#include "neostats.h"
|
||||
#include "ircstring.h"
|
||||
|
||||
#ifdef KAZLIB_RCSID
|
||||
static const char rcsid[] = "$Id$";
|
||||
|
@ -192,7 +191,7 @@ grow_table (hash_t * hash)
|
|||
|
||||
nassert (2 * hash->nchains > hash->nchains); /* 1 */
|
||||
|
||||
newtable = realloc (hash->table, sizeof *newtable * hash->nchains * 2); /* 4 */
|
||||
newtable = srealloc (hash->table, sizeof *newtable * hash->nchains * 2); /* 4 */
|
||||
|
||||
if (newtable) { /* 5 */
|
||||
hash_val_t mask = (hash->mask << 1) | 1; /* 3 */
|
||||
|
@ -279,7 +278,7 @@ shrink_table (hash_t * hash)
|
|||
else
|
||||
nassert (hash->table[chain] == NULL); /* 6 */
|
||||
}
|
||||
newtable = realloc (hash->table, sizeof *newtable * nchains); /* 7 */
|
||||
newtable = srealloc (hash->table, sizeof *newtable * nchains); /* 7 */
|
||||
if (newtable) /* 8 */
|
||||
hash->table = newtable;
|
||||
hash->mask >>= 1; /* 9 */
|
||||
|
@ -327,10 +326,10 @@ hash_create (hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun)
|
|||
if (hash_val_t_bit == 0) /* 1 */
|
||||
compute_bits ();
|
||||
|
||||
hash = malloc (sizeof *hash); /* 2 */
|
||||
hash = smalloc (sizeof (*hash)); /* 2 */
|
||||
|
||||
if (hash) { /* 3 */
|
||||
hash->table = malloc (sizeof *hash->table * INIT_SIZE); /* 4 */
|
||||
hash->table = smalloc (sizeof *hash->table * INIT_SIZE); /* 4 */
|
||||
if (hash->table) { /* 5 */
|
||||
hash->nchains = INIT_SIZE; /* 6 */
|
||||
hash->highmark = INIT_SIZE * 2;
|
||||
|
@ -348,7 +347,7 @@ hash_create (hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun)
|
|||
nassert (hash_verify (hash));
|
||||
return hash;
|
||||
}
|
||||
free (hash);
|
||||
sfree (hash);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -412,8 +411,8 @@ hash_destroy (hash_t * hash)
|
|||
{
|
||||
nassert (hash_val_t_bit != 0);
|
||||
nassert (hash_isempty (hash));
|
||||
free (hash->table);
|
||||
free (hash);
|
||||
sfree (hash->table);
|
||||
sfree (hash);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -785,13 +784,13 @@ hash_isempty (hash_t * hash)
|
|||
static hnode_t *
|
||||
hnode_alloc (void *context)
|
||||
{
|
||||
return malloc (sizeof *hnode_alloc (NULL));
|
||||
return smalloc (sizeof *hnode_alloc (NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
hnode_free (hnode_t * node, void *context)
|
||||
{
|
||||
free (node);
|
||||
sfree (node);
|
||||
}
|
||||
|
||||
|
||||
|
@ -802,7 +801,7 @@ hnode_free (hnode_t * node, void *context)
|
|||
hnode_t *
|
||||
hnode_create (void *data)
|
||||
{
|
||||
hnode_t *node = malloc (sizeof *node);
|
||||
hnode_t *node = smalloc (sizeof *node);
|
||||
if (node) {
|
||||
node->data = data;
|
||||
node->next = NULL;
|
||||
|
@ -829,7 +828,7 @@ hnode_init (hnode_t * hnode, void *data)
|
|||
void
|
||||
hnode_destroy (hnode_t * hnode)
|
||||
{
|
||||
free (hnode);
|
||||
sfree (hnode);
|
||||
}
|
||||
|
||||
#undef hnode_put
|
||||
|
|
24
src/ircd.c
24
src/ircd.c
|
@ -262,7 +262,7 @@ CloakHost (Bot *bot_ptr)
|
|||
/** @brief split_buf
|
||||
* Taken from Epona - Thanks!
|
||||
* Split a buffer into arguments and store the arguments in an
|
||||
* argument vector pointed to by argv (which will be malloc'd
|
||||
* argument vector pointed to by argv (which will be alloced
|
||||
* as necessary); return the argument count. If colon_special
|
||||
* is non-zero, then treat a parameter with a leading ':' as
|
||||
* the last parameter of the line, per the IRC RFC. Destroys
|
||||
|
@ -279,14 +279,14 @@ splitbuf (char *buf, char ***argv, int colon_special)
|
|||
char *s;
|
||||
int colcount = 0;
|
||||
SET_SEGV_LOCATION();
|
||||
*argv = calloc (sizeof (char *) * argvsize, 1);
|
||||
*argv = scalloc (sizeof (char *) * argvsize);
|
||||
argc = 0;
|
||||
/*if (*buf == ':')
|
||||
buf++;*/
|
||||
while (*buf) {
|
||||
if (argc == argvsize) {
|
||||
argvsize += 8;
|
||||
*argv = realloc (*argv, sizeof (char *) * argvsize);
|
||||
*argv = srealloc (*argv, sizeof (char *) * argvsize);
|
||||
}
|
||||
if ((*buf == ':') && (colcount < 1)) {
|
||||
buf++;
|
||||
|
@ -322,14 +322,14 @@ split_buf (char *buf, char ***argv, int colon_special)
|
|||
char *s;
|
||||
int colcount = 0;
|
||||
SET_SEGV_LOCATION();
|
||||
*argv = calloc (sizeof (char *) * argvsize, 1);
|
||||
*argv = scalloc (sizeof (char *) * argvsize);
|
||||
argc = 0;
|
||||
if (*buf == ':')
|
||||
buf++;
|
||||
while (*buf) {
|
||||
if (argc == argvsize) {
|
||||
argvsize += 8;
|
||||
*argv = realloc (*argv, sizeof (char *) * argvsize);
|
||||
*argv = srealloc (*argv, sizeof (char *) * argvsize);
|
||||
}
|
||||
if ((*buf == ':') && (colcount < 1)) {
|
||||
buf++;
|
||||
|
@ -364,7 +364,7 @@ joinbuf (char **av, int ac, int from)
|
|||
int i;
|
||||
char *buf;
|
||||
|
||||
buf = malloc (BUFSIZE);
|
||||
buf = smalloc (BUFSIZE);
|
||||
/* from is zero based while ac has base of 1.
|
||||
* Therefore we need to check >= before trying to perform
|
||||
* the join.
|
||||
|
@ -531,7 +531,7 @@ parse (char *line)
|
|||
nlog (LOG_DEBUG1, "args : %s", coreLine);
|
||||
ac = splitbuf (coreLine, &av, 1);
|
||||
process_ircd_cmd (cmdptr, cmd, origin, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
nlog (LOG_DEBUG1, "---------------------------END PARSE----------------------------");
|
||||
}
|
||||
#endif
|
||||
|
@ -575,7 +575,7 @@ do_pong (const char* origin, const char* destination)
|
|||
cmdparams = (CmdParams*)scalloc (sizeof(CmdParams));
|
||||
cmdparams->source.server = s;
|
||||
SendAllModuleEvent (EVENT_PONG, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
return;
|
||||
}
|
||||
nlog (LOG_NOTICE, "Received PONG from unknown server: %s", origin);
|
||||
|
@ -958,7 +958,7 @@ scmode_op (const char *who, const char *chan, const char *mode, const char *bot)
|
|||
ircsnprintf (ircd_buf, BUFSIZE, "%s %s %s", chan, mode, bot);
|
||||
ac = split_buf (ircd_buf, &av, 0);
|
||||
ChanMode (me.name, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
@ -973,7 +973,7 @@ schmode_cmd (const char *who, const char *chan, const char *mode, const char *ar
|
|||
ircsnprintf (ircd_buf, BUFSIZE, "%s %s %s", chan, mode, args);
|
||||
ac = split_buf (ircd_buf, &av, 0);
|
||||
ChanMode (me.name, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1240,7 @@ ssjoin_cmd (const char *who, const char *chan, unsigned long chflag)
|
|||
ircsnprintf (ircd_buf, BUFSIZE, "%s +%c %s", chan, mode, who);
|
||||
ac = split_buf (ircd_buf, &av, 0);
|
||||
ChanMode (me.name, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1401,7 +1401,7 @@ do_sjoin (char* tstime, char* channame, char *modes, char *sjoinnick, char **arg
|
|||
}
|
||||
}
|
||||
}
|
||||
free(param);
|
||||
sfree(param);
|
||||
}
|
||||
|
||||
#ifdef MSG_NETINFO
|
||||
|
|
20
src/list.c
20
src/list.c
|
@ -91,7 +91,7 @@ list_init (list_t * list, listcount_t maxcount)
|
|||
}
|
||||
|
||||
/*
|
||||
* Dynamically allocate a list object using malloc(), and initialize it so that
|
||||
* Dynamically allocate a list object and initialize it so that
|
||||
* it is a valid empty list. If the list is to be ``unbounded'', the maxcount
|
||||
* should be specified as LISTCOUNT_T_MAX, or, alternately, as -1.
|
||||
*/
|
||||
|
@ -99,7 +99,7 @@ list_init (list_t * list, listcount_t maxcount)
|
|||
list_t *
|
||||
list_create (listcount_t maxcount)
|
||||
{
|
||||
list_t *new = malloc (sizeof *new);
|
||||
list_t *new = smalloc (sizeof *new);
|
||||
if (new) {
|
||||
nassert (maxcount != 0);
|
||||
new->nilnode.next = &new->nilnode;
|
||||
|
@ -119,7 +119,7 @@ void
|
|||
list_destroy (list_t * list)
|
||||
{
|
||||
nassert (list_isempty (list));
|
||||
free (list);
|
||||
sfree (list);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -262,7 +262,7 @@ list_process (list_t * list, void *context, void (*function) (list_t * list, lno
|
|||
lnode_t *
|
||||
lnode_create (void *data)
|
||||
{
|
||||
lnode_t *new = malloc (sizeof *new);
|
||||
lnode_t *new = smalloc (sizeof *new);
|
||||
if (new) {
|
||||
new->data = data;
|
||||
new->next = NULL;
|
||||
|
@ -292,7 +292,7 @@ void
|
|||
lnode_destroy (lnode_t * lnode)
|
||||
{
|
||||
nassert (!lnode_is_in_a_list (lnode));
|
||||
free (lnode);
|
||||
sfree (lnode);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -331,12 +331,12 @@ lnode_pool_create (listcount_t n)
|
|||
|
||||
nassert (n != 0);
|
||||
|
||||
pool = malloc (sizeof *pool);
|
||||
pool = smalloc (sizeof *pool);
|
||||
if (!pool)
|
||||
return NULL;
|
||||
nodes = malloc (n * sizeof *nodes);
|
||||
nodes = smalloc (n * sizeof *nodes);
|
||||
if (!nodes) {
|
||||
free (pool);
|
||||
sfree (pool);
|
||||
return NULL;
|
||||
}
|
||||
lnode_pool_init (pool, nodes, n);
|
||||
|
@ -370,8 +370,8 @@ lnode_pool_isfrom (lnodepool_t * pool, lnode_t * node)
|
|||
void
|
||||
lnode_pool_destroy (lnodepool_t * p)
|
||||
{
|
||||
free (p->pool);
|
||||
free (p);
|
||||
sfree (p->pool);
|
||||
sfree (p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -112,7 +112,7 @@ CloseLogs (void)
|
|||
}
|
||||
hash_scan_delete (logs, hn);
|
||||
hnode_destroy (hn);
|
||||
free (logentry);
|
||||
sfree (logentry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ FiniLogs (void)
|
|||
}
|
||||
hash_scan_delete (logs, hn);
|
||||
hnode_destroy (hn);
|
||||
free (logentry);
|
||||
sfree (logentry);
|
||||
}
|
||||
/* for some reason, the logs are not getting flushed correctly */
|
||||
hash_destroy(logs);
|
||||
|
@ -206,7 +206,7 @@ nlog (LOG_LEVEL level, char *fmt, ...)
|
|||
if(!logentry->logfile)
|
||||
logentry->logfile = fopen (logentry->logname, "a");
|
||||
} else {
|
||||
logentry = malloc (sizeof (struct logs_));
|
||||
logentry = smalloc (sizeof (struct logs_));
|
||||
strlcpy (logentry->name, GET_CUR_MODNAME() , MAX_MOD_NAME);
|
||||
make_log_filename(logentry->name, logentry->logname);
|
||||
logentry->logfile = fopen (logentry->logname, "a");
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
|
||||
#include "neostats.h"
|
||||
#include "ircstring.h"
|
||||
|
||||
/* match()
|
||||
*
|
||||
|
|
93
src/misc.c
93
src/misc.c
|
@ -29,7 +29,6 @@
|
|||
|
||||
static char misc_buf[BUFSIZE];
|
||||
|
||||
|
||||
/** @brief strip newlines carriage returns
|
||||
*
|
||||
* removes newlines and carriage returns from a string
|
||||
|
@ -48,60 +47,104 @@ strip (char *line)
|
|||
*c = '\0';
|
||||
}
|
||||
|
||||
/** @brief NeoStats implementation of malloc.
|
||||
/** @brief NeoStats wrapper for malloc.
|
||||
*
|
||||
* Allocates memory for internal variables. Useful for memory debugging
|
||||
* if enough memory can't be malloced, exit the program
|
||||
* Allocates memory for internal variables.
|
||||
* If enough memory can't be allocated, exit the program
|
||||
*
|
||||
* @param size The amount of memory to alloc
|
||||
*
|
||||
* @returns size bytes of memory or NULL on error
|
||||
* @returns pointer to allocated buffer
|
||||
*/
|
||||
|
||||
void *
|
||||
smalloc (long size)
|
||||
void * smalloc ( const int size )
|
||||
{
|
||||
unsigned int allocsize;
|
||||
void *buf;
|
||||
|
||||
if (!size) {
|
||||
nlog (LOG_WARNING, "smalloc(): illegal attempt to allocate 0 bytes!");
|
||||
size = 1;
|
||||
allocsize = size;
|
||||
if (!allocsize) {
|
||||
nlog (LOG_WARNING, "smalloc: illegal attempt to allocate 0 bytes!");
|
||||
allocsize = 1;
|
||||
}
|
||||
buf = malloc (size);
|
||||
buf = malloc (allocsize);
|
||||
if (!buf) {
|
||||
nlog (LOG_CRITICAL, "smalloc(): out of memory.");
|
||||
nlog (LOG_CRITICAL, "smalloc: out of memory.");
|
||||
do_exit (NS_EXIT_ERROR, "Out of memory");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** @brief NeoStats implementation of calloc.
|
||||
/** @brief NeoStats wrapper for calloc.
|
||||
*
|
||||
* Allocates memory for internal variables. Useful for memory debugging
|
||||
* if enough memory can't be malloced, exit the program
|
||||
* Allocates memory for internal variables.
|
||||
* If enough memory can't be allocated, exit the program
|
||||
*
|
||||
* @param size The amount of memory to alloc
|
||||
*
|
||||
* @returns size bytes of memory or NULL on error
|
||||
* @returns pointer to allocated buffer
|
||||
*/
|
||||
|
||||
void *
|
||||
scalloc (long size)
|
||||
void * scalloc ( const int size )
|
||||
{
|
||||
void *buf;
|
||||
unsigned int allocsize;
|
||||
|
||||
if (!size) {
|
||||
nlog (LOG_WARNING, "scalloc(): illegal attempt to allocate 0 bytes!");
|
||||
size = 1;
|
||||
allocsize = size;
|
||||
if (!allocsize) {
|
||||
nlog (LOG_WARNING, "scalloc: illegal attempt to allocate 0 bytes!");
|
||||
allocsize = 1;
|
||||
}
|
||||
buf = calloc (1, size);
|
||||
buf = calloc (1, allocsize);
|
||||
if (!buf) {
|
||||
nlog (LOG_CRITICAL, "scalloc(): out of memory.");
|
||||
nlog (LOG_CRITICAL, "scalloc: out of memory.");
|
||||
do_exit (NS_EXIT_ERROR, "Out of memory");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/** @brief NeoStats wrapper for realloc.
|
||||
*
|
||||
* Reallocates memory
|
||||
* If enough memory can't be allocated, exit the program
|
||||
*
|
||||
* @param size The amount of memory to realloc
|
||||
*
|
||||
* @returns pointer to allocated buffer
|
||||
*/
|
||||
|
||||
void * srealloc ( void* ptr, const int size )
|
||||
{
|
||||
void* newptr;
|
||||
|
||||
newptr = realloc (ptr, size);
|
||||
if (!newptr) {
|
||||
nlog (LOG_CRITICAL, "srealloc: out of memory.");
|
||||
do_exit (NS_EXIT_ERROR, "Out of memory");
|
||||
}
|
||||
return newptr;
|
||||
}
|
||||
|
||||
/** @brief NeoStats wrapper for free.
|
||||
*
|
||||
* Free memory associated with pointer.
|
||||
* If NULL pointer log error and ignore free
|
||||
*
|
||||
* @param size Pointer to buffer to free
|
||||
*
|
||||
* @returns none
|
||||
*/
|
||||
|
||||
void sfree ( void *buf )
|
||||
{
|
||||
if (!buf) {
|
||||
nlog (LOG_WARNING, "sfree: illegal attempt to free NULL pointer");
|
||||
return;
|
||||
}
|
||||
free (buf);
|
||||
buf = 0;
|
||||
}
|
||||
|
||||
/** @brief Duplicate a string
|
||||
*
|
||||
* make a copy of a string, with memory allocated for the new string
|
||||
|
@ -166,10 +209,10 @@ AddStringToList (char ***List, char S[], int *C)
|
|||
|
||||
if (*C == 0) {
|
||||
numargs = 8;
|
||||
*List = calloc (sizeof (char *) * numargs, 1);
|
||||
*List = scalloc (sizeof (char *) * numargs);
|
||||
} else if (*C == numargs) {
|
||||
numargs += 8;
|
||||
*List = realloc (*List, sizeof (char *) * numargs);
|
||||
*List = srealloc (*List, sizeof (char *) * numargs);
|
||||
}
|
||||
++*C;
|
||||
(*List)[*C - 1] = S;
|
||||
|
|
|
@ -386,7 +386,7 @@ load_module (char *modfilename, User * u)
|
|||
}
|
||||
nlog (LOG_WARNING, "Unable to load module: module list is full");
|
||||
ns_dlclose (dl_handle);
|
||||
free (mod_ptr);
|
||||
sfree (mod_ptr);
|
||||
return NULL;
|
||||
}
|
||||
hash_insert (mh, mn, info_ptr->name);
|
||||
|
@ -414,7 +414,7 @@ load_module (char *modfilename, User * u)
|
|||
}
|
||||
nlog (LOG_WARNING, "Unable to load module: %s missing ModInit.", mod_ptr->info->name);
|
||||
ns_dlclose (dl_handle);
|
||||
free (mod_ptr);
|
||||
sfree (mod_ptr);
|
||||
return NULL;
|
||||
} else {
|
||||
int err;
|
||||
|
@ -440,7 +440,7 @@ load_module (char *modfilename, User * u)
|
|||
event_ptr->function (NULL);
|
||||
RESET_RUN_LEVEL();
|
||||
SET_SEGV_LOCATION();
|
||||
free (av);
|
||||
sfree (av);
|
||||
break;
|
||||
}
|
||||
event_ptr++;
|
||||
|
@ -540,7 +540,7 @@ unload_module (const char *modname, User * u)
|
|||
nlog (LOG_DEBUG1, "Free %d from Module Numbers", i);
|
||||
ModList[i] = NULL;
|
||||
}
|
||||
free (mod_ptr);
|
||||
sfree (mod_ptr);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ ModuleConfig(bot_setting* set_ptr)
|
|||
case SET_TYPE_IPV4:
|
||||
if(GetConf((void *) &temp, CFGSTR, set_ptr->confitem) > 0) {
|
||||
strlcpy(set_ptr->varptr, temp, MAXNICK);
|
||||
free(temp);
|
||||
sfree(temp);
|
||||
} else {
|
||||
strlcpy(set_ptr->varptr, set_ptr->defaultval, set_ptr->max);
|
||||
|
||||
|
|
|
@ -237,10 +237,10 @@ static int cs_event_quit(CmdParams* cmdparams)
|
|||
cmdparams->source.user->nick, cmdparams->source.user->username,
|
||||
cmdparams->source.user->hostname,
|
||||
Local[6], KillMsg);
|
||||
free(KillMsg);
|
||||
free(QuitMsg);
|
||||
free(cmd);
|
||||
free(lcl);
|
||||
sfree(KillMsg);
|
||||
sfree(QuitMsg);
|
||||
sfree(cmd);
|
||||
sfree(lcl);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -251,10 +251,10 @@ static int cs_event_quit(CmdParams* cmdparams)
|
|||
cmdparams->source.user->hostname, cmdparams->source.user->realname,
|
||||
cmdparams->source.user->server->name, QuitMsg);
|
||||
}
|
||||
free(QuitMsg);
|
||||
free(cmd);
|
||||
free(lcl);
|
||||
free(Quit);
|
||||
sfree(QuitMsg);
|
||||
sfree(cmd);
|
||||
sfree(lcl);
|
||||
sfree(Quit);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -477,8 +477,8 @@ static int cs_event_kill(CmdParams* cmdparams)
|
|||
cmdparams->source.user->hostname,
|
||||
Kill[0], GlobalMsg);
|
||||
}
|
||||
free(cmd);
|
||||
free(GlobalMsg);
|
||||
sfree(cmd);
|
||||
sfree(GlobalMsg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void ModFini()
|
|||
|
||||
un = list_first(srconf.ul);
|
||||
while (un) {
|
||||
free(lnode_get(un));
|
||||
sfree(lnode_get(un));
|
||||
un = list_next(srconf.ul, un);
|
||||
}
|
||||
list_destroy_nodes(srconf.ul);
|
||||
|
@ -135,7 +135,7 @@ void sr_cb_config(char *arg, int configtype)
|
|||
nick = strtok(arg, "!");
|
||||
user = strtok(NULL, "@");
|
||||
host = strtok(NULL, "");
|
||||
sru = malloc(sizeof(users));
|
||||
sru = smalloc(sizeof(users));
|
||||
strlcpy(sru->nick, nick, MAXNICK);
|
||||
strlcpy(sru->ident, user, MAXUSER);
|
||||
strlcpy(sru->host, host, MAXHOST);
|
||||
|
|
|
@ -172,7 +172,7 @@ void save_vhost(hs_map *vhost)
|
|||
void del_vhost(hs_map *vhost)
|
||||
{
|
||||
DelRow("Vhosts", vhost->nnick);
|
||||
free(vhost);
|
||||
sfree(vhost);
|
||||
/* no need to list sort here, because its already sorted */
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ void set_moddata(User* u)
|
|||
hs_user *hs;
|
||||
|
||||
if (!u->moddata[hs_module->modnum]) {
|
||||
hs = malloc(sizeof(hs_user));
|
||||
hs = smalloc(sizeof(hs_user));
|
||||
hs->vhostset = 1;
|
||||
u->moddata[hs_module->modnum] = hs;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ static int hs_event_quit(CmdParams* cmdparams)
|
|||
{
|
||||
if (cmdparams->source.user->moddata[hs_module->modnum]) {
|
||||
nlog(LOG_DEBUG2, "hs_event_quit: free module data");
|
||||
free(cmdparams->source.user->moddata[hs_module->modnum]);
|
||||
sfree(cmdparams->source.user->moddata[hs_module->modnum]);
|
||||
cmdparams->source.user->moddata[hs_module->modnum] = NULL;
|
||||
}
|
||||
return 1;
|
||||
|
@ -279,7 +279,7 @@ void ModFini()
|
|||
|
||||
hn = list_first(vhosts);
|
||||
while (hn != NULL) {
|
||||
free(lnode_get(hn));
|
||||
sfree(lnode_get(hn));
|
||||
hn = list_next(vhosts, hn);
|
||||
}
|
||||
list_destroy_nodes(vhosts);
|
||||
|
@ -346,7 +346,7 @@ static void hsdat(char *nick, char *host, char *vhost, char *pass, char *who)
|
|||
lnode_t *hn;
|
||||
hs_map *map;
|
||||
|
||||
map = malloc(sizeof(hs_map));
|
||||
map = smalloc(sizeof(hs_map));
|
||||
strlcpy(map->nnick, nick, MAXNICK);
|
||||
strlcpy(map->host, host, MAXHOST);
|
||||
strlcpy(map->vhost, vhost, MAXHOST);
|
||||
|
@ -466,7 +466,7 @@ static void hs_addban(User* u, char *ban)
|
|||
"%s already exists in the banned vhost list", ban);
|
||||
return;
|
||||
}
|
||||
host = malloc(MAXHOST);
|
||||
host = smalloc(MAXHOST);
|
||||
strlcpy(host, ban, MAXHOST);
|
||||
hn = hnode_create(host);
|
||||
hash_insert(bannedvhosts, hn, host);
|
||||
|
@ -506,7 +506,7 @@ static void hs_delban(User* u, char *ban)
|
|||
nlog(LOG_NOTICE,
|
||||
"%s deleted %s from the banned vhost list",
|
||||
u->nick, (char *) hnode_get(hn));
|
||||
free(hnode_get(hn));
|
||||
sfree(hnode_get(hn));
|
||||
hnode_destroy(hn);
|
||||
SaveBans();
|
||||
return;
|
||||
|
@ -761,7 +761,7 @@ static void LoadHosts()
|
|||
if (GetTableData("Vhosts", &LoadArry) > 0) {
|
||||
load_synch = 1;
|
||||
for (count = 0; LoadArry[count] != NULL; count++) {
|
||||
map = malloc(sizeof(hs_map));
|
||||
map = smalloc(sizeof(hs_map));
|
||||
strlcpy(map->nnick, LoadArry[count], MAXNICK);
|
||||
if (GetData((void *)&tmp, CFGSTR, "Vhosts", map->nnick, "Host") > 0)
|
||||
strlcpy(map->host, tmp, MAXHOST);
|
||||
|
@ -778,7 +778,7 @@ static void LoadHosts()
|
|||
map->nnick, map->vhost);
|
||||
}
|
||||
}
|
||||
free(LoadArry);
|
||||
sfree(LoadArry);
|
||||
list_sort(vhosts, findnick);
|
||||
}
|
||||
|
||||
|
@ -920,12 +920,12 @@ static void LoadConfig(void)
|
|||
host = strtok(temp, ";");
|
||||
while (host != NULL) {
|
||||
/* limit host to MAXHOST and avoid unterminated/huge strings */
|
||||
host2 = malloc(MAXHOST);
|
||||
host2 = smalloc(MAXHOST);
|
||||
strlcpy(host2, host, MAXHOST);
|
||||
hn = hnode_create(host2);
|
||||
hash_insert(bannedvhosts, hn, host2);
|
||||
host = strtok(NULL, ";");
|
||||
}
|
||||
free(temp);
|
||||
sfree(temp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ static int ls_lovenote(CmdParams* cmdparams)
|
|||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s has sent you a love note which reads: \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
free(message);
|
||||
sfree(message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ static int ls_apology(CmdParams* cmdparams)
|
|||
prefmsg(target_nick, ls_bot->nick,
|
||||
"%s is sorry, and would like to apologise for \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
free(message);
|
||||
sfree(message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -275,6 +275,6 @@ static int ls_thankyou(CmdParams* cmdparams)
|
|||
"Thank you sent to %s", target_nick);
|
||||
prefmsg(target_nick, ls_bot->nick, "%s wishes to thank you for \2%s\2",
|
||||
cmdparams->source.user->nick, message);
|
||||
free(message);
|
||||
sfree(message);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ void LoadServerStats(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
sfree(row);
|
||||
}
|
||||
|
||||
void LoadStats(void)
|
||||
|
@ -180,7 +180,7 @@ CStats *load_chan(char *name)
|
|||
CStats *c;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
c = malloc(sizeof(CStats));
|
||||
c = smalloc(sizeof(CStats));
|
||||
#ifdef USE_BERKELEY
|
||||
if ((data = DBGetData(name)) != NULL) {
|
||||
memcpy(c, data, sizeof(CStats));
|
||||
|
@ -189,7 +189,7 @@ CStats *load_chan(char *name)
|
|||
if (GetData((void *)&data, CFGSTR, "ChanStats", c->name, "ChanData") > 0) {
|
||||
sscanf(data, "%ld %ld %ld %ld %ld %ld %ld %ld %ld", &c->topics, &c->totmem, &c->kicks, &c->maxmems, &c->t_maxmems, &c->maxkicks, &c->t_maxkicks, &c->maxjoins, &c->t_maxjoins);
|
||||
GetData((void *)&c->lastseen, CFGINT, "ChanStats", c->name, "LastSeen");
|
||||
free(data);
|
||||
sfree(data);
|
||||
#endif
|
||||
} else {
|
||||
strlcpy(c->name, name, CHANLEN);
|
||||
|
@ -302,7 +302,7 @@ int DelOldChan(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
free(row);
|
||||
sfree(row);
|
||||
nlog(LOG_INFO, "DelOldChan: %d seconds %d channels", (int)(time(NULL) - start), count);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -83,9 +83,9 @@ int ss_html()
|
|||
"Failed to open HTML output file %s. Check file permissions.", StatServ.htmlpath);
|
||||
return 1;
|
||||
}
|
||||
buf = malloc(STARTBUFSIZE * 2);
|
||||
buf = smalloc(STARTBUFSIZE * 2);
|
||||
bufold = buf;
|
||||
buf1 = malloc(STARTBUFSIZE * 2);
|
||||
buf1 = smalloc(STARTBUFSIZE * 2);
|
||||
while (fgets(buf, STARTBUFSIZE, tpl)) {
|
||||
|
||||
buf1 = strstr(buf, "!MAP!");
|
||||
|
@ -193,8 +193,8 @@ int ss_html()
|
|||
|
||||
fputs(buf, opf);
|
||||
}
|
||||
free(buf1);
|
||||
free(bufold);
|
||||
sfree(buf1);
|
||||
sfree(bufold);
|
||||
if (!gothtml) {
|
||||
put_copyright();
|
||||
}
|
||||
|
|
|
@ -110,11 +110,10 @@ static CVersions *findctcpversion(char *name)
|
|||
cn = list_find(Vhead, name, comparef);
|
||||
if (cn) {
|
||||
cv = lnode_get(cn);
|
||||
} else {
|
||||
nlog(LOG_DEBUG2, "findctcpversion(%s) -> NOT FOUND", name);
|
||||
return NULL;
|
||||
return cv;
|
||||
}
|
||||
return cv;
|
||||
nlog(LOG_DEBUG2, "findctcpversion(%s) -> NOT FOUND", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int save_client_versions(void)
|
||||
|
@ -146,7 +145,7 @@ int load_client_versions(void)
|
|||
input = fopen("data/ssversions.dat", "rb");
|
||||
if(input) {
|
||||
while(!feof(input)) {
|
||||
clientv = malloc(sizeof(CVersions));
|
||||
clientv = smalloc(sizeof(CVersions));
|
||||
fread(clientv, sizeof(CVersions), 1, input);
|
||||
node = lnode_create(clientv);
|
||||
list_append(Vhead, node);
|
||||
|
@ -215,7 +214,7 @@ void StatsAddCTCPVersion(char* version)
|
|||
clientv->count++;
|
||||
return;
|
||||
}
|
||||
clientv = malloc(sizeof(CVersions));
|
||||
clientv = smalloc(sizeof(CVersions));
|
||||
strlcpy(clientv->name, nocols, BUFSIZE);
|
||||
clientv->count = 1;
|
||||
node = lnode_create(clientv);
|
||||
|
@ -234,7 +233,7 @@ void StatsDelChan(Channel* c)
|
|||
save_chan(cs);
|
||||
list_delete(Chead, ln);
|
||||
lnode_destroy(ln);
|
||||
free(cs);
|
||||
sfree(cs);
|
||||
} else {
|
||||
nlog(LOG_WARNING, "Couldn't find channel %s when deleting from stats", c->name);
|
||||
}
|
||||
|
@ -328,9 +327,6 @@ SStats *newserverstats(const char *name)
|
|||
SET_SEGV_LOCATION();
|
||||
nlog(LOG_DEBUG2, "newserverstats(%s)", name);
|
||||
s = scalloc(sizeof(SStats));
|
||||
if (!s) {
|
||||
FATAL_ERROR("Out of memory.")
|
||||
}
|
||||
memcpy(s->name, name, MAXHOST);
|
||||
s->t_maxusers = me.now;
|
||||
s->t_maxopers = me.now;
|
||||
|
@ -341,7 +337,7 @@ SStats *newserverstats(const char *name)
|
|||
sn = hnode_create(s);
|
||||
if (hash_isfull(Shead)) {
|
||||
nlog(LOG_CRITICAL, "StatServ Server hash is full!");
|
||||
free(s);
|
||||
sfree(s);
|
||||
return NULL;
|
||||
}
|
||||
hash_insert(Shead, sn, s->name);
|
||||
|
@ -466,7 +462,7 @@ void StatsKillUser(User* u)
|
|||
ss = findserverstats(who);
|
||||
ss->serverkills ++;
|
||||
}
|
||||
free(rbuf);
|
||||
sfree(rbuf);
|
||||
}
|
||||
|
||||
void StatsUserMode(User* u, char *modes)
|
||||
|
@ -629,7 +625,7 @@ void FiniStats(void)
|
|||
hash_scan_begin(&ss, Shead);
|
||||
while ((sn = hash_scan_next(&ss))) {
|
||||
s = hnode_get(sn);
|
||||
free(s);
|
||||
sfree(s);
|
||||
hash_scan_delete(Shead, sn);
|
||||
hnode_destroy(sn);
|
||||
}
|
||||
|
@ -637,7 +633,7 @@ void FiniStats(void)
|
|||
cn = list_first(Chead);
|
||||
while (cn) {
|
||||
c = lnode_get(cn);
|
||||
free(c);
|
||||
sfree(c);
|
||||
cn = list_next(Chead, cn);
|
||||
}
|
||||
list_destroy_nodes(Chead);
|
||||
|
|
|
@ -867,7 +867,7 @@ static int ss_stats(CmdParams* cmdparams)
|
|||
hash_delete(Shead, node);
|
||||
st = hnode_get(node);
|
||||
hnode_destroy(node);
|
||||
free(st);
|
||||
sfree(st);
|
||||
prefmsg(cmdparams->source.user->nick, ss_bot->nick, "Removed %s from the database.",
|
||||
cmdparams->av[1]);
|
||||
nlog(LOG_NOTICE, "%s requested STATS DEL %s", cmdparams->source.user->nick, cmdparams->av[1]);
|
||||
|
@ -892,7 +892,7 @@ static int ss_stats(CmdParams* cmdparams)
|
|||
}
|
||||
st = findserverstats(cmdparams->av[2]);
|
||||
if (st)
|
||||
free(st);
|
||||
sfree(st);
|
||||
|
||||
st = findserverstats(cmdparams->av[1]);
|
||||
if (!st) {
|
||||
|
|
|
@ -50,7 +50,7 @@ void ResetTLD()
|
|||
/* don't delete the tld entry ??? as its our "unknown" entry */
|
||||
if (ircstrcasecmp(t->tld, "???")) {
|
||||
tn2 = list_next(Thead, tn);
|
||||
free(t);
|
||||
sfree(t);
|
||||
list_delete(Thead, tn);
|
||||
lnode_destroy(tn);
|
||||
tn = tn2;
|
||||
|
@ -142,7 +142,7 @@ void AddTLD(User * u)
|
|||
t->daily_users++;
|
||||
} else {
|
||||
country_name = GeoIP_country_name_by_addr(gi, ipaddr);
|
||||
t = malloc(sizeof(TLD));
|
||||
t = smalloc(sizeof(TLD));
|
||||
strlcpy(t->tld, country_code, 5);
|
||||
strlcpy(t->country, country_name, 32);
|
||||
t->users = 1;
|
||||
|
@ -193,7 +193,7 @@ void FiniTLD(void)
|
|||
tn = list_first(Thead);
|
||||
while (tn != NULL) {
|
||||
t = lnode_get(tn);
|
||||
free(t);
|
||||
sfree(t);
|
||||
tn = list_next(Thead, tn);
|
||||
}
|
||||
list_destroy_nodes(Thead);
|
||||
|
|
|
@ -803,8 +803,10 @@ void fatal_error(char* file, int line, char* func, char* error_text) __attribute
|
|||
|
||||
/* misc.c */
|
||||
void strip (char * line);
|
||||
void *smalloc (long size);
|
||||
void *scalloc (long size);
|
||||
void *smalloc ( const int size );
|
||||
void *scalloc ( const int size );
|
||||
void *srealloc ( void* ptr, const int size );
|
||||
void sfree ( void *buf );
|
||||
char *sstrdup (const char * s);
|
||||
char *strlwr (char * s);
|
||||
void AddStringToList (char ***List, char S[], int *C);
|
||||
|
|
|
@ -577,7 +577,7 @@ m_away (char *origin, char **argv, int argc, int srv)
|
|||
if (argc > 0) {
|
||||
buf = joinbuf (argv, argc, 0);
|
||||
do_away (base64tonick(origin), buf);
|
||||
free (buf);
|
||||
sfree (buf);
|
||||
} else {
|
||||
do_away (base64tonick(origin), NULL);
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ m_burst (char *origin, char **argv, int argc, int srv)
|
|||
ircsnprintf (ircd_buf, BUFSIZE, "%s +%c %s", argv[0], modechar, base64tonick(s));
|
||||
ac = split_buf (ircd_buf, &av, 0);
|
||||
ChanMode (me.name, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
}
|
||||
}
|
||||
param++;
|
||||
|
@ -786,7 +786,7 @@ m_burst (char *origin, char **argv, int argc, int srv)
|
|||
}
|
||||
ac = split_buf (ircd_buf, &av, 0);
|
||||
ChanMode (me.name, av, ac);
|
||||
free (av);
|
||||
sfree (av);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ parse (char *line)
|
|||
nlog (LOG_DEBUG1, "0 %d", ac);
|
||||
}
|
||||
process_ircd_cmd (cmdptr, cmd, origin, av, ac);
|
||||
if(av) free (av);
|
||||
if(av) sfree (av);
|
||||
nlog (LOG_DEBUG1, "---------------------------END PARSE----------------------------");
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ ircu_m_private (char *origin, char **argv, int argc, int srv)
|
|||
AddStringToList (&av, argv[i], &ac);
|
||||
}
|
||||
m_private (base64tonick(origin), av, ac, srv);
|
||||
free (av);
|
||||
sfree (av);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -922,5 +922,5 @@ ircu_m_notice (char *origin, char **argv, int argc, int srv)
|
|||
AddStringToList (&av, argv[i], &ac);
|
||||
}
|
||||
m_notice (base64tonick(origin), av, ac, srv);
|
||||
free (av);
|
||||
sfree (av);
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ new_server (const char *name)
|
|||
sn = hnode_create (s);
|
||||
if (!sn) {
|
||||
nlog (LOG_WARNING, "Server hash broken");
|
||||
free (s);
|
||||
sfree (s);
|
||||
return NULL;
|
||||
}
|
||||
if (hash_isfull (sh)) {
|
||||
nlog (LOG_WARNING, "Server hash full");
|
||||
free (s);
|
||||
sfree (s);
|
||||
return NULL;
|
||||
} else {
|
||||
hash_insert (sh, sn, s->name);
|
||||
|
@ -89,7 +89,7 @@ AddServer (const char *name, const char *uplink, const char* hops, const char *n
|
|||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->source.server = s;
|
||||
SendAllModuleEvent (EVENT_SERVER, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
return(s);
|
||||
}
|
||||
|
||||
|
@ -114,10 +114,10 @@ DelServer (const char *name, const char* reason)
|
|||
cmdparams->param = (char*)reason;
|
||||
}
|
||||
SendAllModuleEvent (EVENT_SQUIT, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
hash_delete (sh, sn);
|
||||
hnode_destroy (sn);
|
||||
free (s);
|
||||
sfree (s);
|
||||
}
|
||||
|
||||
#ifdef BASE64SERVERNAME
|
||||
|
@ -340,7 +340,7 @@ FiniServers (void)
|
|||
s = hnode_get (sn);
|
||||
hash_delete (sh, sn);
|
||||
hnode_destroy (sn);
|
||||
free (s);
|
||||
sfree (s);
|
||||
}
|
||||
hash_destroy(sh);
|
||||
}
|
||||
|
|
|
@ -431,7 +431,7 @@ ns_raw (CmdParams* cmdparams)
|
|||
chanalert (ns_botptr->nick, "\2RAW COMMAND\2 \2%s\2 issued a raw command!(%s)", cmdparams->source.user->nick, message);
|
||||
nlog (LOG_INFO, "RAW COMMAND %s issued a raw command!(%s)", cmdparams->source.user->nick, message);
|
||||
send_cmd ("%s", message);
|
||||
free (message);
|
||||
sfree (message);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -110,7 +110,7 @@ void do_backtrace(void)
|
|||
for (i = 1; i < size; i++) {
|
||||
fprintf (segfault, "BackTrace(%d): %s\n", i - 1, strings[i]);
|
||||
}
|
||||
free (strings);
|
||||
sfree (strings);
|
||||
#else
|
||||
fprintf (segfault, backtrace_unavailable);
|
||||
#endif
|
||||
|
|
34
src/sock.c
34
src/sock.c
|
@ -39,7 +39,6 @@
|
|||
#include "dns.h"
|
||||
#include "transfer.h"
|
||||
#include "curl.h"
|
||||
#include "ircstring.h"
|
||||
#include "dotconf.h"
|
||||
#ifdef SQLSRV
|
||||
#include "sqlsrv/rta.h"
|
||||
|
@ -56,6 +55,8 @@ static hash_t *sockh;
|
|||
/* @brief server socket */
|
||||
static int servsock;
|
||||
char recbuf[BUFSIZE];
|
||||
static struct timeval *TimeOut;
|
||||
static struct pollfd *ufds;
|
||||
|
||||
#ifdef SQLSRV
|
||||
|
||||
|
@ -122,7 +123,7 @@ ConnectTo (char *host, int port)
|
|||
}
|
||||
|
||||
if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
free(hp);
|
||||
sfree(hp);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
if (dobind > 0) {
|
||||
|
@ -163,13 +164,12 @@ static void
|
|||
read_loop ()
|
||||
{
|
||||
register int i, j, SelectResult;
|
||||
struct timeval *TimeOut, tvbuf;
|
||||
struct timeval tvbuf;
|
||||
fd_set readfds, writefds, errfds;
|
||||
int maxfdsunused;
|
||||
char c;
|
||||
char buf[BUFSIZE];
|
||||
Sock *sock;
|
||||
struct pollfd *ufds;
|
||||
int pollsize, pollflag;
|
||||
hscan_t ss;
|
||||
hnode_t *sn;
|
||||
|
@ -178,10 +178,6 @@ read_loop ()
|
|||
Sql_Conn *sqldata;
|
||||
#endif
|
||||
|
||||
/* XXX Valgrind reports these two as lost memory, Should clean up before we exit */
|
||||
TimeOut = malloc (sizeof (struct timeval));
|
||||
ufds = malloc((sizeof *ufds) * me.maxsocks);
|
||||
|
||||
me.lastmsg = me.now;
|
||||
while (1) {
|
||||
SET_SEGV_LOCATION();
|
||||
|
@ -426,10 +422,12 @@ getmaxsock (void)
|
|||
struct rlimit *lim;
|
||||
int ret;
|
||||
|
||||
lim = malloc (sizeof (struct rlimit));
|
||||
lim = smalloc (sizeof (struct rlimit));
|
||||
getrlimit (RLIMIT_NOFILE, lim);
|
||||
ret = lim->rlim_max;
|
||||
free (lim);
|
||||
sfree (lim);
|
||||
if(ret<0)
|
||||
ret = 0xffff;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -677,7 +675,7 @@ sql_accept_conn(int srvfd)
|
|||
|
||||
/* We have a new UI/DB/manager connection request. So make a free
|
||||
slot and allocate it */
|
||||
newui = malloc(sizeof(Sql_Conn));
|
||||
newui = smalloc(sizeof(Sql_Conn));
|
||||
|
||||
|
||||
/* OK, we've got the ui slot, now accept the conn */
|
||||
|
@ -687,7 +685,7 @@ sql_accept_conn(int srvfd)
|
|||
if (newui->fd < 0)
|
||||
{
|
||||
nlog(LOG_WARNING, "SqlSrv: Manager accept() error (%s). \n", strerror(errno));
|
||||
free(newui);
|
||||
sfree(newui);
|
||||
close(srvfd);
|
||||
return;
|
||||
}
|
||||
|
@ -698,7 +696,7 @@ sql_accept_conn(int srvfd)
|
|||
/* we didnt get a match, bye bye */
|
||||
nlog(LOG_NOTICE, "SqlSrv: Rejecting SQL Connection from %s", tmp);
|
||||
close(newui->fd);
|
||||
free(newui);
|
||||
sfree(newui);
|
||||
return;
|
||||
}
|
||||
/* inc number ui, then init new ui */
|
||||
|
@ -761,7 +759,7 @@ sql_handle_ui_request(lnode_t *sqlnode)
|
|||
close(sqlconn->fd);
|
||||
list_delete(sqlconnections, sqlnode);
|
||||
lnode_destroy(sqlnode);
|
||||
free(sqlconn);
|
||||
sfree(sqlconn);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
sqlconn->cmdpos += ret;
|
||||
|
@ -819,7 +817,7 @@ sql_handle_ui_output(lnode_t *sqlnode)
|
|||
close(sqlconn->fd);
|
||||
list_delete(sqlconnections, sqlnode);
|
||||
lnode_destroy(sqlnode);
|
||||
free(sqlconn);
|
||||
sfree(sqlconn);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
else if (ret == (50000 - sqlconn->responsefree))
|
||||
|
@ -850,11 +848,15 @@ int InitSocks (void)
|
|||
nlog (LOG_CRITICAL, "Unable to create socks hash");
|
||||
return NS_FAILURE;
|
||||
}
|
||||
TimeOut = smalloc (sizeof (struct timeval));
|
||||
ufds = smalloc((sizeof *ufds) * me.maxsocks);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
int FiniSocks (void)
|
||||
{
|
||||
sfree(TimeOut);
|
||||
sfree(ufds);
|
||||
if (servsock > 0)
|
||||
close (servsock);
|
||||
hash_destroy(sockh);
|
||||
|
@ -1010,7 +1012,7 @@ del_socket (char *sock_name)
|
|||
nlog (LOG_DEBUG2, "del_socket: Unregistered Socket function %s from Module %s", sock_name, sock->moduleptr->info->name);
|
||||
hash_scan_delete (sockh, sn);
|
||||
hnode_destroy (sn);
|
||||
free (sock);
|
||||
sfree (sock);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_FAILURE;
|
||||
|
|
|
@ -169,10 +169,7 @@ char *strndup(const char *src, size_t count)
|
|||
}
|
||||
|
||||
/* Allocate count plus one for trailing NULL */
|
||||
dup = (char*)malloc(count+1);
|
||||
if (!dup) {
|
||||
return NULL;
|
||||
}
|
||||
dup = (char*)smalloc(count+1);
|
||||
|
||||
/* Copy string into created buffer */
|
||||
memcpy(dup, src, count);
|
||||
|
|
|
@ -121,7 +121,7 @@ new_timer (char *name)
|
|||
|
||||
SET_SEGV_LOCATION();
|
||||
nlog (LOG_DEBUG2, "new_timer: %s", name);
|
||||
timer = malloc (sizeof (Timer));
|
||||
timer = smalloc (sizeof (Timer));
|
||||
strlcpy (timer->name, name, MAX_MOD_NAME);
|
||||
tn = hnode_create (timer);
|
||||
if (hash_isfull (th)) {
|
||||
|
@ -207,7 +207,7 @@ del_timer (char *name)
|
|||
nlog (LOG_DEBUG2, "del_timer: Unregistered Timer function %s from Module %s", name, timer->moduleptr->info->name);
|
||||
hash_delete (th, tn);
|
||||
hnode_destroy (tn);
|
||||
free (timer);
|
||||
sfree (timer);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
return NS_FAILURE;
|
||||
|
@ -321,7 +321,7 @@ run_mod_timers (void)
|
|||
nlog(LOG_DEBUG2, "run_mod_timers: Deleting Timer %s for Module %s as requested", timer->name, timer->moduleptr->info->name);
|
||||
hash_scan_delete(th, tn);
|
||||
hnode_destroy(tn);
|
||||
free(timer);
|
||||
sfree(timer);
|
||||
} else {
|
||||
timer->lastrun = (int) me.now;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ static size_t neocurl_callback( void *transferptr, size_t size, size_t nmemb, vo
|
|||
size *= nmemb;
|
||||
rembuffer = neotrans->savememsize - neotrans->savemempos; /* the remianing buffer size */
|
||||
if (size > rembuffer) {
|
||||
newbuf = realloc(neotrans->savemem, neotrans->savememsize + (size - rembuffer));
|
||||
newbuf = srealloc(neotrans->savemem, neotrans->savememsize + (size - rembuffer));
|
||||
if (newbuf == NULL) {
|
||||
nlog(LOG_WARNING, "Ran out of Memory for transfer %s. %s", neotrans->url, strerror(errno));
|
||||
return -1;
|
||||
|
@ -117,14 +117,14 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
/* if we don't have a filename, bail out */
|
||||
if (filename[0] == 0) {
|
||||
nlog(LOG_WARNING, "Undefined Filename for new_transfer URL %s, Aborting", url);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
newtrans->savefile = fopen(filename, "w");
|
||||
if (!newtrans->savefile) {
|
||||
nlog(LOG_WARNING, "Error Opening file for writting in new_transfer: %s", strerror(errno));
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
newtrans->savefileormem = NS_FILE;
|
||||
|
@ -147,14 +147,14 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
newtrans->curleasyhandle = curl_easy_init();
|
||||
if (!newtrans->curleasyhandle) {
|
||||
nlog(LOG_WARNING, "Curl Easy Init Failed for url %s", url);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
/* setup some standard options we use globally */
|
||||
if ((ret = curl_easy_setopt(newtrans->curleasyhandle, CURLOPT_ERRORBUFFER, newtrans->curlerror)) != 0 ) {
|
||||
nlog(LOG_WARNING, "Curl set errorbuffer failed. Returned %d for url %s", ret, url);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
@ -163,7 +163,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
@ -172,7 +172,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set useragent failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -241,14 +241,14 @@ int new_transfer(char *url, char *params, NS_TRANSFER savetofileormemory, char *
|
|||
nlog(LOG_WARNING, "Curl Set nosignal failed. Returned %d for url %s", ret, url);
|
||||
nlog(LOG_WARNING, "Error Was: %s", newtrans->curlerror);
|
||||
curl_easy_cleanup(newtrans->curleasyhandle);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
if (!curl_multi_add_handle(curlmultihandle, newtrans->curleasyhandle)) {
|
||||
nlog(LOG_WARNING, "Curl Init Failed: %s", newtrans->curlerror);
|
||||
free(newtrans);
|
||||
sfree(newtrans);
|
||||
return NS_FAILURE;
|
||||
}
|
||||
/* we have to do this at least once to get things going */
|
||||
|
@ -295,8 +295,8 @@ void transfer_status(void)
|
|||
curl_easy_cleanup(neotrans->curleasyhandle);
|
||||
/* XXX remove from list */
|
||||
if (neotrans->savefileormem == NS_MEMORY)
|
||||
free(neotrans->savemem);
|
||||
free(neotrans);
|
||||
sfree(neotrans->savemem);
|
||||
sfree(neotrans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
24
src/users.c
24
src/users.c
|
@ -77,7 +77,7 @@ static void lookupnickip(char *data, adns_answer *a)
|
|||
cmdparams = (CmdParams*) scalloc (sizeof(CmdParams));
|
||||
cmdparams->source.user = u;
|
||||
SendAllModuleEvent (EVENT_GOTNICKIP, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -106,12 +106,12 @@ AddUser (const char *nick, const char *user, const char *host, const char *realn
|
|||
#ifndef GOTNICKIP
|
||||
} else if (me.want_nickip == 1) {
|
||||
/* first, if the u->host is a ip address, just convert it */
|
||||
ipad = malloc(sizeof(struct in_addr));
|
||||
ipad = smalloc(sizeof(struct in_addr));
|
||||
res = inet_aton(host, ipad);
|
||||
if (res > 0) {
|
||||
/* its valid */
|
||||
ipaddress = htonl(ipad->s_addr);
|
||||
free(ipad);
|
||||
sfree(ipad);
|
||||
} else {
|
||||
/* kick of a dns reverse lookup for this host */
|
||||
dns_lookup((char *)host, adns_r_addr, lookupnickip, (void *)nick);
|
||||
|
@ -156,7 +156,7 @@ AddUser (const char *nick, const char *user, const char *host, const char *realn
|
|||
/* only fire this event if we have the nickip and some module wants it */
|
||||
SendAllModuleEvent (EVENT_GOTNICKIP, cmdparams);
|
||||
}
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
/* Send CTCP VERSION request if we are configured to do so */
|
||||
if(me.versionscan && !IsExcluded(u)) {
|
||||
privmsg(u->nick, ns_botptr->nick, "\1VERSION\1");
|
||||
|
@ -179,7 +179,7 @@ static void deluser(User* u)
|
|||
hash_delete (uh, un);
|
||||
hnode_destroy (un);
|
||||
list_destroy (u->chans);
|
||||
free (u);
|
||||
sfree (u);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -209,7 +209,7 @@ KillUser (const char *nick, const char *reason)
|
|||
SendModuleEvent (EVENT_BOTKILL, cmdparams, findbot(u->nick));
|
||||
}
|
||||
deluser(u);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -234,7 +234,7 @@ QuitUser (const char *nick, const char *reason)
|
|||
}
|
||||
SendAllModuleEvent (EVENT_QUIT, cmdparams);
|
||||
deluser(u);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -261,7 +261,7 @@ UserAway (const char *nick, const char *awaymsg)
|
|||
u->is_away = 1;
|
||||
}
|
||||
SendAllModuleEvent (EVENT_AWAY, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -302,7 +302,7 @@ UserNick (const char * oldnick, const char *newnick, const char * ts)
|
|||
cmdparams->source.user = u;
|
||||
cmdparams->param = (char *)oldnick;
|
||||
SendAllModuleEvent (EVENT_NICK, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
return NS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -709,7 +709,7 @@ UserMode (const char *nick, const char *modes)
|
|||
cmdparams->source.user = u;
|
||||
cmdparams->param = (char*)modes;
|
||||
SendAllModuleEvent (EVENT_UMODE, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
|
||||
#ifdef GOTUSERSMODES
|
||||
|
@ -733,7 +733,7 @@ UserSMode (const char *nick, const char *modes)
|
|||
cmdparams->source.user = u;
|
||||
cmdparams->param = modes;
|
||||
SendAllModuleEvent (EVENT_SMODE, cmdparams);
|
||||
free (cmdparams);
|
||||
sfree (cmdparams);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -768,7 +768,7 @@ void FiniUsers (void)
|
|||
hash_scan_delete (uh, un);
|
||||
hnode_destroy (un);
|
||||
list_destroy (u->chans);
|
||||
free (u);
|
||||
sfree (u);
|
||||
}
|
||||
hash_destroy(uh);
|
||||
}
|
||||
|
|
Reference in a new issue