Free() panics are no longer deadly

This commit is contained in:
joonicks 2018-03-27 23:26:34 +02:00
parent 7c5611931b
commit d9fac6178c
8 changed files with 62 additions and 16 deletions

View File

@ -1,5 +1,7 @@
3.0.99p4 -- WORK IN PROGRESS (~March, 2018)
* Changed: If compiled with debug, Free() on unknown memory no longer shuts down the bot,
now it just ignores the panic and swallows the (possible) leak.
* Added: Experimental code to suppress certain commands to run on only one bot even
if command is issued in public.
* Added: Some example ascii art: bbw, camel, goatse, mech, phooler

2
configure vendored
View File

@ -1011,7 +1011,7 @@ test -z "$ans" -o "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$
def_suppress='#undef SUPPRESS'
unset ans
$out $ac_n "[ ALPHA] Command duplication suppression? ............ [Y/n] "$ac_c
$out $ac_n "[ ALPHA] Command duplication suppression? ........... [Y/n] "$ac_c
test "$ft_suppress" && $out "$ft_suppress" && ans=$ft_suppress
test -z "$ft_suppress" && read ans
test -z "$ans" -o "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_suppress='#define SUPPRESS'

View File

@ -126,7 +126,8 @@ void Free(char **mem)
{
debug("(Free) PANIC: Free(0x"mx_pfmt"); Unregistered memory block\n",(mx_ptr)src);
run_debug();
exit(1);
//exit(1); // overreacting. just ignore it and accept the leak.
return;
}
mp = mp->next;
}

View File

@ -82,6 +82,7 @@ BEG int makecore MDEF(FALSE);
BEG int respawn MDEF(0);
BEG int sigmaster MDEF(0);
BEG int ctimeout MDEF(30); /* proc var */
BEG int startup MDEF(TRUE);
BEG ino_t parent_inode;
BEG KillSock *killsocks MDEF(NULL);

View File

@ -818,6 +818,9 @@ int main(int argc, char **argv, char **envp)
char *opt;
int do_fork = TRUE;
int versiononly = FALSE;
#ifdef NEWBIE
int n = 0;
#endif
uptime = time(&now);
@ -1017,12 +1020,12 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
LocalBot.x.x.aop = 1;
LocalBot.chan = CoreUser.chan = (Strp*)&CMA;
readcfgfile();
#ifdef UPTIME
init_uptime();
#endif /* UPTIME */
readcfgfile();
#ifndef I_HAVE_A_LEGITIMATE_NEED_FOR_MORE_THAN_4_BOTS
if (spawning_lamer > 4)
{
@ -1035,7 +1038,20 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
{
if ((opt = current->setting[STR_USERFILE].str_var))
read_userlist(opt);
#ifdef NEWBIE
if (current->userlist == NULL)
{
to_file(1,"init: No userlist loaded for %s\n",nullstr(current->nick));
n++;
}
}
if (n)
{
_exit(1);
}
#else
}
#endif /* NEWBIE */
for(current=botlist;current;current=current->next)
{
mirror_userlist();
@ -1104,5 +1120,6 @@ execve( ./energymech, argv = { ./energymech <NULL> <NULL> <NULL> <NULL> }, envp
#endif /* DEBUG */
}
startup = FALSE;
doit();
}

View File

@ -149,12 +149,8 @@ int read_bigcharset(char *fname)
{
bigc = orig_fontlist;
orig_fontlist = bigc->next;
while(bigc->data)
{
sp = bigc->data;
bigc->data = sp->next;
Free((char**)&sp);
}
if (bigc->data)
purge_strplist(bigc->data);
Free((char**)&bigc);
}

View File

@ -56,6 +56,7 @@ void urlcapture(const char *rest)
if (n <= 0)
{
purge_strplist(sp->next);
sp->next = NULL;
return;
}
n--;

View File

@ -296,36 +296,64 @@ int read_userlist(char *filename)
int in;
#ifdef DEBUG
int r;
#endif
#ifdef DEBUG
if (!filename)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE filename empty\n");
#endif /* NEWBIE */
debug("(read_userlist) filename is NULL\n");
return(FALSE);
}
if (*filename == '<') // read only userfile
filename++;
if ((r = is_safepath(filename,FILE_MUST_EXIST)) != FILE_IS_SAFE)
if ((r = is_safepath(filename,FILE_MAY_EXIST)) != FILE_IS_SAFE)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE filename is unsafe\n");
#endif /* NEWBIE */
debug("(read_userlist) %s: unsafe filename (%i)...\n",filename,r);
return(FALSE);
}
if ((in = open(filename,O_RDONLY)) < 0)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE \"%s\": %s\n",filename,strerror(errno));
#endif /* NEWBIE */
debug("(read_userlist) failed to open \"%s\": %s\n",filename,strerror(errno));
return(FALSE);
}
#else
#else /* ifdef DEBUG */
if (!filename)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE filename empty\n");
#endif /* NEWBIE */
return(FALSE);
}
if (*filename == '<') // read only userfile
filename++;
if (is_safepath(filename,FILE_MUST_EXIST) != FILE_IS_SAFE)
if (is_safepath(filename,FILE_MAY_EXIST) != FILE_IS_SAFE)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE filename is unsafe\n");
#endif /* NEWBIE */
return(FALSE);
}
if ((in = open(filename,O_RDONLY)) < 0)
{
#ifdef NEWBIE
if (startup)
to_file(1,"read_userlist: USERFILE \"%s\": %s\n",filename,strerror(errno));
#endif /* NEWBIE */
return(FALSE);
#endif
}
#endif /* ifdef DEBUG */
olduserlist = current->userlist;
cfgUser = current->userlist = NULL;