url crash fix

This commit is contained in:
joonicks 2018-03-26 00:37:57 +02:00
parent 9664b98665
commit 06be1ee4d2
25 changed files with 111 additions and 128 deletions

20
configure vendored
View File

@ -21,7 +21,7 @@
umask 077
# perl still unsupported
has_perl=no
#has_perl=no
compile=no
install=no
silentopt=no
@ -1127,15 +1127,15 @@ fi
# perl support not yet functional (2009-05-11)
#
def_perl='#undef PERL'
# unset ans
# echo $ac_n "Perl scripting support? .................... [y/N] "$ac_c
# if [ "$has_perl" = no ]; then
# echo 'no (unsupported)'
# else
# test "$ft_perl" && echo "$ft_perl" && ans=$ft_perl
# test -z "$ft_perl" && read ans
# test "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_perl='#define PERL'
# fi
unset ans
echo $ac_n "[ ALPHA] Perl scripting support? .................... [y/N] "$ac_c
if [ "$has_perl" = no ]; then
echo 'no (unsupported)'
else
test "$ft_perl" && echo "$ft_perl" && ans=$ft_perl
test -z "$ft_perl" && read ans
test "$ans" = y -o "$ans" = Y -o "$ans" = yes -o "$ans" = YES -o "$ans" = Yes && def_perl='#define PERL'
fi
def_python='#undef PYTHON'
unset ans

View File

@ -274,7 +274,6 @@ LS char *au_userhost;
LS char *au_channel;
LS int au_access;
__attr(CORE_SEG, __regparm (1) )
void aucheck(User *user)
{
Strp *ump;

View File

@ -58,7 +58,6 @@ void check_idlekick(void)
}
}
__attr(CORE_SEG, __regparm(2))
Chan *find_channel(const char *name, int anychannel)
{
Chan *chan;
@ -78,13 +77,11 @@ Chan *find_channel(const char *name, int anychannel)
return(NULL);
}
__attr(CORE_SEG, __regparm (1))
Chan *find_channel_ac(const char *name)
{
return(find_channel(name,CHAN_ACTIVE));
}
__attr(CORE_SEG, __regparm (1))
Chan *find_channel_ny(const char *name)
{
return(find_channel(name,CHAN_ANY));
@ -546,7 +543,6 @@ void channel_massunban(Chan *chan, char *pattern, time_t seconds)
* for each nickcmp call, 10-15% cpu is saved by skipping one char
* into both nicks (first-char comparison has already been made).
*/
__attr(CORE_SEG, __regparm (2) )
ChanUser *find_chanuser(Chan *chan, const char *nick)
{
ChanUser *cu;
@ -578,7 +574,6 @@ ChanUser *find_chanuser(Chan *chan, const char *nick)
return(NULL);
}
__attr(CORE_SEG, __regparm (2) )
void remove_chanuser(Chan *chan, char *nick)
{
ChanUser *cu,**pp;
@ -625,7 +620,6 @@ void remove_chanuser(Chan *chan, char *nick)
/*
* Requires CurrentChan to be set properly
*/
__attr(CORE_SEG, __regparm(2))
void make_chanuser(char *nick, char *userhost)
{
ChanUser *new;

View File

@ -391,7 +391,7 @@ void signoff(char *from, char *reason)
#endif /* NOTIFY */
if (from)
{
to_user(from,"ShutDown Complete");
to_user(from,TEXT_SHUTDOWNCOMPLETE);
}
while(current->chanlist)

View File

@ -141,6 +141,7 @@ LS struct
{ make_ban, "make_ban" },
{ make_chanuser, "make_chanuser" },
{ make_ireq, "make_ireq" },
{ make_strp, "make_strp" },
{ mirror_user, "mirror_user" },
{ on_join, "on_join" },
{ on_kick, "on_kick" },

View File

@ -43,7 +43,6 @@ LS const char daylist[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
#ifdef DEBUG
__attr(CORE_SEG,__regparm(1))
void *Calloc(int size)
{
aME *mmep;
@ -98,7 +97,6 @@ void *Calloc(int size)
return((void*)mmep->area+4);
}
__attr(CORE_SEG,__regparm(1))
void Free(char **mem)
{
aME *mmep;
@ -145,7 +143,6 @@ void Free(char **mem)
#else /* DEBUG */
__attr(CORE_SEG,__regparm(1))
void *Calloc(int size)
{
void *tmp;
@ -158,7 +155,6 @@ void *Calloc(int size)
/*
* Free() can be called with NULL's
*/
__attr(CORE_SEG,__regparm(1))
void Free(char **mem)
{
if (*mem)
@ -170,7 +166,70 @@ void Free(char **mem)
#endif /* DEBUG */
const int Strlen(const char *first, ...)
Strp *make_strp(Strp **pp, const char *string)
{
set_mallocdoer(make_strp);
*pp = (Strp*)Calloc(sizeof(Strp) + strlen(string));
Strcpy((*pp)->p,string);
return(*pp);
}
Strp *append_strp(Strp **pp, const char *string)
{
while((*pp)->next != NULL)
pp = &((*pp)->next);
make_strp(pp,string);
return(*pp);
}
Strp *prepend_strp(Strp **pp, const char *string)
{
Strp *sp;
make_strp(&sp,string);
sp->next = *pp;
*pp = sp;
return(sp);
}
void purge_strplist(Strp *sp)
{
Strp *nxt;
debug("do...\n");
while(sp)
{
debug("nxt =...\n");
nxt = sp->next;
debug("free...\n");
Free((char**)&sp);
debug("sp = nx\n");
sp = nxt;
debug("while..\n");
}
}
/*
* duplicate a list of Strp
*/
void dupe_strp(Strp *sp, Strp **pp)
{
while(sp)
{
make_strp(pp,sp->p);
pp = &((*pp)->next);
sp = sp->next;
/*
set_mallocdoer(dupe_strp);
*pp = (Strp*)Calloc(sizeof(Strp) + strlen(sp->p));
Strcpy((*pp)->p,sp->p);
pp = &((*pp)->next);
sp = sp->next;
*/
}
}
const int StrlenX(const char *first, ...)
{
const char *s,*o;
int n;
@ -193,7 +252,6 @@ const int Strlen(const char *first, ...)
return(n);
}
__attr(CORE_SEG,__regparm(2))
const int Strlen2(const char *one, const char *two)
{
const char *s1,*s2;
@ -206,7 +264,6 @@ const int Strlen2(const char *one, const char *two)
return((s1 - one) + (s2 - two));
}
__attr(CORE_SEG,__regparm(2))
char *nickcpy(char *dest, const char *nuh)
{
char *ret;
@ -405,7 +462,6 @@ char *idle2str(time_t when, int small)
return(idlestr);
}
__attr(CMD1_SEG,__regparm(2))
char *get_channel(char *to, char **rest)
{
char *channel;
@ -658,7 +714,6 @@ int capslevel(char *text)
return(upper >= sz);
}
__attr(CORE_SEG,__regparm(1))
int a2i(char *anum)
{
int res = 0,neg;
@ -698,7 +753,6 @@ int get_number(const char *rest)
return(n);
}
__attr(CORE_SEG,__regparm(1))
void fix_config_line(char *text)
{
char *s,*space;
@ -720,7 +774,6 @@ void fix_config_line(char *text)
/*
* returns NULL or non-zero length string
*/
__attr(CORE_SEG,__regparm(1))
char *chop(char **src)
{
char *tok,*cut = *src;
@ -749,7 +802,6 @@ char *chop(char **src)
/*
* remove all '\0' in an array bounded by two pointers
*/
__attr(CORE_SEG,__regparm(2))
void unchop(char *orig, char *rest)
{
for(;orig<rest;orig++)
@ -759,7 +811,6 @@ void unchop(char *orig, char *rest)
}
}
__att2(CORE_SEG,const,__regparm(2))
int Strcasecmp(const char *p1, const char *p2)
{
int ret;
@ -773,7 +824,6 @@ int Strcasecmp(const char *p1, const char *p2)
return(0);
}
__att2(CORE_SEG,const,__regparm(2))
int Strcmp(const char *p1, const char *p2)
{
int ret;
@ -787,7 +837,6 @@ int Strcmp(const char *p1, const char *p2)
return(0);
}
__att2(CORE_SEG,const,__regparm(2))
int nickcmp(const char *p1, const char *p2)
{
int ret;
@ -802,7 +851,6 @@ int nickcmp(const char *p1, const char *p2)
return(0);
}
__attr(CORE_SEG,__regparm(3))
void Strncpy(char *dst, const char *src, int sz)
{
char *stop = dst + sz - 1;
@ -816,7 +864,6 @@ void Strncpy(char *dst, const char *src, int sz)
*dst = 0;
}
__attr(CORE_SEG,__regparm(2))
char *Strcpy(char *dst, const char *src)
{
while(*src)
@ -825,7 +872,6 @@ char *Strcpy(char *dst, const char *src)
return(dst);
}
__att2(CORE_SEG,const,__regparm(2))
char *Strchr(const char *t, int c)
{
char ch = c;
@ -835,7 +881,6 @@ char *Strchr(const char *t, int c)
return((*t == ch) ? (char*)t : NULL);
}
__attr(CORE_SEG,__regparm(1))
char *Strdup(const char *src)
{
char *dest;
@ -845,7 +890,6 @@ char *Strdup(const char *src)
return(dest);
}
__attr(CMD1_SEG,__regparm(2))
char *tolowercat(char *dest, const char *src)
{
dest = STREND(dest);
@ -858,7 +902,6 @@ char *tolowercat(char *dest, const char *src)
* This code might look odd but its optimized for size,
* so dont change it!
*/
__attr(CORE_SEG,__regparm(2))
char *Strcat(char *dst, const char *src)
{
while(*(dst++))
@ -874,7 +917,6 @@ char *Strcat(char *dst, const char *src)
* returns 0 for match
* returns 1 for non-match
*/
__att2(CORE_SEG,const,__regparm(2))
int matches(const char *mask, const char *text)
{
const uchar *m = (uchar*)mask;
@ -949,7 +991,6 @@ loop:
goto loop;
}
__att2(CORE_SEG,const,__regparm(2))
int num_matches(const char *mask, const char *text)
{
const char *p = mask;
@ -989,7 +1030,6 @@ void table_buffer(const char *format, ...)
Strcpy((*sp)->p,gsockdata);
}
__attr(CMD1_SEG, __regparm (2) )
void table_send(const char *from, const int space)
{
char message[MAXLEN];
@ -1103,7 +1143,6 @@ int is_safepath(const char *path)
#define FILE_MAY_EXIST 2
#define FILE_MUST_NOTEXIST 3
__attr(CORE_SEG,__regparm(2))
int is_safepath(const char *path, int filemustexist)
{
struct stat st;

View File

@ -80,7 +80,7 @@ void greet(void)
{
str = CurrentUser->greet;
single_line:
*pp = sp = (Strp*)Calloc(sizeof(Strp) + 13 + Strlen(CurrentChan->name,CurrentNick,str,NULL));
*pp = sp = (Strp*)Calloc(sizeof(Strp) + 13 + StrlenX(CurrentChan->name,CurrentNick,str,NULL));
sprintf(sp->p,"PRIVMSG %s :[%s] %s",CurrentChan->name,CurrentNick,str);
/* Calloc sets to zero sp->next = NULL; */
}

View File

@ -138,7 +138,14 @@ void do_crash(COMMAND_ARGS) __page(RARE_SEG);
LS void *Calloc(int) __attr(CORE_SEG, __regparm(1));
LS void Free(char **) __attr(CORE_SEG, __regparm(1));
LS const int Strlen(const char *, ...) __page(CORE_SEG);
LS Strp *make_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *append_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS Strp *prepend_strp(Strp **, const char *) __attr(CORE_SEG, __regparm(2));
LS void purge_strplist(Strp *) __attr(CORE_SEG, __regparm(1));
LS void dupe_strp(Strp *, Strp **) __attr(CORE_SEG, __regparm(2));
LS const int StrlenX(const char *, ...) __attr(CORE_SEG, __regparm(1));
LS const int Strlen2(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int matches(const char *, const char *) __attr(CORE_SEG, __regparm(2));
LS int num_matches(const char *, const char *) __attr(CORE_SEG, __regparm(2));

View File

@ -241,7 +241,6 @@ void usage_command(char *to, const char *arg)
to_user(to,"Usage: (missing)");
}
__attr(CMD1_SEG,__regparm(1))
void usage(char *to)
{
CurrentChan = NULL;

View File

@ -37,7 +37,7 @@ void make_ireq(int t, char *from, char *nick)
char *pt;
set_mallocdoer(make_ireq);
ir = (IReq*)Calloc(sizeof(IReq) + Strlen(from,nick,NULL)); // can not use Strlen2() if 2nd arg might be NULL, Strlen() handles NULLs.
ir = (IReq*)Calloc(sizeof(IReq) + StrlenX(from,nick,NULL)); // can not use Strlen2() if 2nd arg might be NULL, StrlenX() handles NULLs.
ir->t = t;
ir->when = now;

View File

@ -210,7 +210,7 @@ void do_kicksay(COMMAND_ARGS)
* add it to the list
*/
set_mallocdoer(do_kicksay);
kick = (KickSay*)Calloc(sizeof(KickSay) + Strlen(channel,mask,rest,NULL));
kick = (KickSay*)Calloc(sizeof(KickSay) + StrlenX(channel,mask,rest,NULL));
kick->next = current->kicklist;
current->kicklist = kick;

View File

@ -157,7 +157,7 @@ BotInfo *make_botinfo(int guid, int hops, char *nuh, char *server, char *version
BotInfo *new;
set_mallocdoer(make_botinfo);
new = (BotInfo*)Calloc(sizeof(BotInfo) + Strlen(nuh,server,version,NULL));
new = (BotInfo*)Calloc(sizeof(BotInfo) + StrlenX(nuh,server,version,NULL));
new->guid = guid;
new->hops = hops;
@ -210,7 +210,6 @@ void botnet_refreshbotinfo(void)
#endif /* DEBUG */
}
__attr(CORE_SEG, __regparm (2))
void botnet_binfo_relay(BotNet *source, BotInfo *binfo)
{
botnet_relay(source,"BL%i %i %s %s %s\n",binfo->guid,(binfo->hops + 1),
@ -219,7 +218,6 @@ void botnet_binfo_relay(BotNet *source, BotInfo *binfo)
(binfo->version) ? binfo->version : "-");
}
__attr(CORE_SEG, __regparm (2))
void botnet_binfo_tofile(int sock, BotInfo *binfo)
{
to_file(sock,"BL%i %i %s %s %s\n",binfo->guid,(binfo->hops + 1),
@ -1567,7 +1565,7 @@ usage:
goto usage;
set_mallocdoer(do_link);
cfg = (NetCfg*)Calloc(sizeof(NetCfg) + Strlen(pass,host,NULL)); // host might be NULL, Strlen() handles NULLs, Strlen2() does not.
cfg = (NetCfg*)Calloc(sizeof(NetCfg) + StrlenX(pass,host,NULL)); // host might be NULL, StrlenX() handles NULLs, Strlen2() does not.
cfg->guid = iguid;
cfg->port = iport;

View File

@ -61,13 +61,7 @@ int catch_note(char *from, char *to, char *rest)
}
if (!(u = find_handle(n->user)))
return(TRUE);
np = &u->note;
while(*np)
np = &(*np)->next;
set_mallocdoer(catch_note);
*np = sp = (Strp*)Calloc(sizeof(Strp) + strlen(rest));
/* Calloc sets to zero sp->next = NULL; */
Strcpy(sp->p,rest);
append_strp(&u->note,rest);
return(TRUE);
}
if ((now - n->start) > 120)
@ -106,7 +100,7 @@ void do_note(COMMAND_ARGS)
u->name);
set_mallocdoer(do_note);
n = Calloc(sizeof(Note) + Strlen(from,to,u->name,NULL));
n = Calloc(sizeof(Note) + StrlenX(from,to,u->name,NULL));
n->start = now;
n->next = notelist;
notelist = n;
@ -122,13 +116,7 @@ void do_note(COMMAND_ARGS)
* add a note header
*/
sprintf(header,"\001%s %s",from,time2str(now));
np = &u->note;
while(*np)
np = &(*np)->next;
set_mallocdoer(do_note);
*np = sp = (Strp*)Calloc(sizeof(Strp) + strlen(header));
/* Calloc sets to zero sp->next = NULL; */
Strcpy(sp->p,header);
append_strp(&u->note,header);
}
void do_read(COMMAND_ARGS)

View File

@ -442,7 +442,7 @@ int notify_callback(char *rest)
* src = description or NULL
*/
set_mallocdoer(notify_callback);
nf = (Notify*)Calloc(sizeof(Notify) + Strlen(nick,rest,src,NULL));
nf = (Notify*)Calloc(sizeof(Notify) + StrlenX(nick,rest,src,NULL));
dst = Strcat(nf->nick,nick);
if (*rest)
{

View File

@ -558,9 +558,7 @@ PyObject *python_to_server(PyObject *self, PyObject *args, PyObject *keywds)
else
if (sz)
{
*pp = sp = (Strp*) Calloc(sizeof(Strp) + sz);
/* Calloc sets to zero sp->next = NULL; */
Strcpy(sp->p, line);
make_strp(pp,line);
}
}
else

View File

@ -153,7 +153,7 @@ void send_redirect(char *message)
while(*pp)
pp = &(*pp)->next;
*pp = new = (Strp*)Calloc(sizeof(Strp) + Strlen(message,fmt,redirect.to,NULL));
*pp = new = (Strp*)Calloc(sizeof(Strp) + StrlenX(message,fmt,redirect.to,NULL));
/* Calloc sets to zero new->next = NULL; */
sprintf(new->p,fmt,redirect.to,message);
}

View File

@ -186,10 +186,10 @@ step_two:
/*
* dont fuck with this code unless you really know what you're doing
* pa might be NULL, but then pb is NULL also; pb might be NULL
* any NULL terminates the Strlen() check
* any NULL terminates the StrlenX() check
*/
set_mallocdoer(make_seen);
seen = (Seen*)Calloc(sizeof(Seen) + Strlen(nick,userhost,pa,pb,NULL));
seen = (Seen*)Calloc(sizeof(Seen) + StrlenX(nick,userhost,pa,pb,NULL));
seen->next = *pp;
*pp = seen;

View File

@ -136,7 +136,7 @@ Shit *add_shit(char *from, char *chan, char *mask, char *reason, int axs, int ex
Shit *shit;
set_mallocdoer(add_shit);
shit = (Shit*)Calloc(sizeof(Shit) + Strlen(from,chan,mask,reason,NULL));
shit = (Shit*)Calloc(sizeof(Shit) + StrlenX(from,chan,mask,reason,NULL));
shit->action = axs;
shit->time = now;

View File

@ -388,7 +388,7 @@ void to_user_q(const char *target, const char *format, ...)
pp = &(*pp)->next;
set_mallocdoer(to_user_q);
*pp = new = (Strp*)Calloc(sizeof(Strp) + Strlen(fmt,target,message,NULL));
*pp = new = (Strp*)Calloc(sizeof(Strp) + StrlenX(fmt,target,message,NULL));
/* Calloc sets to zero new->next = NULL; */
sprintf(new->p,fmt,target,message);
}

View File

@ -118,11 +118,11 @@
#define TEXT_NAMETOOLONG "Hostname exceeds maximum length"
#define TEXT_SHUTDOWNBY "Shutdown initiated by %s[100], flatlining ..."
#define TEXT_SHUTDOWNCOMPLETE "Shutdown Complete"
/*
* main.c
*/
#define TEXT_SIGINT "Lurking interrupted by luser ... er, owner. (SIGINT)"
#define TEXT_SIGSEGV "Mary had a little signal segmentation fault (SIGSEGV)"
#define TEXT_SIGBUS "Another one drives the bus! (SIGBUS)"

View File

@ -69,13 +69,7 @@ int read_bigcharset_callback(char *rest)
sz = strlen(rest);
if (sz > newchar->width)
newchar->width = sz;
pp = &newchar->data;
while(*pp)
pp = &(*pp)->next;
set_mallocdoer(read_bigcharset_callback);
*pp = sp = (Strp*)Calloc(sizeof(Strp) + sz);
/* Calloc sets to zero sp->next = NULL; */
Strcpy(sp->p,rest);
append_strp(&newchar->data,rest);
return(FALSE);
}

View File

@ -368,7 +368,6 @@ char *random_question(char *triv_rand)
void trivia_question(void)
{
char buffer[MSGLEN];
Strp *ans,**pp;
char *question,*answer,*rest;
if (triv_halt_flag)
@ -392,15 +391,8 @@ stop_trivia:
question = get_token(&rest,MATCH_ALL);
pp = &triv_answers;
while((answer = get_token(&rest,MATCH_ALL)))
{
set_mallocdoer(trivia_question);
*pp = ans = (Strp*)Calloc(sizeof(Strp) + strlen(answer));
pp = &ans->next;
Strcpy(ans->p,answer);
}
*pp = NULL;
append_strp(&triv_answers,answer);
if (triv_answers == NULL)
goto bad_question;

View File

@ -190,7 +190,7 @@ void send_uptime(int type)
}
#endif /* ! RAWDNS */
sz = sizeof(PackStub) + 3 + Strlen(nick,server,VERSION,NULL);
sz = sizeof(PackStub) + 3 + StrlenX(nick,server,VERSION,NULL);
if (sz > sizeof(PackUp))
return;

View File

@ -29,7 +29,6 @@
#include "h.h"
#include "text.h"
__page(CORE_SEG)
void urlcapture(const char *rest)
{
Strp *sp,*nx;
@ -49,23 +48,18 @@ void urlcapture(const char *rest)
if ((n = urlhistmax))
{
set_mallocdoer(urlcapture);
sp = (Strp*)Calloc(sizeof(Strp) + strlen(url));
Strcpy(sp->p,url);
sp->next = urlhistory;
urlhistory = sp;
debug("prepend\n");
prepend_strp(&urlhistory,url);
debug("for...\n");
for(sp=urlhistory;sp;sp=sp->next)
{
if (n <= 0)
{
do
{
nx = sp->next;
Free((char**)&sp);
sp = nx;
}
while(sp);
debug("purge...\n");
purge_strplist(sp->next);
debug("return\n");
return;
}
n--;
}
@ -84,7 +78,6 @@ Display a list of URLs seen by the bot in order most recent to oldest.
[max] Maximum number of URLs to display.
*/
__page(CMD1_SEG)
void do_urlhist(COMMAND_ARGS)
{
Strp *sp;

View File

@ -479,7 +479,6 @@ int write_userlist(char *filename)
* remfromuser() remove a channel or mask from a user
*/
__page(CORE_SEG)
void rehash_chanusers(void)
{
Chan *chan;
@ -492,7 +491,6 @@ void rehash_chanusers(void)
}
}
__attr(CORE_SEG, __regparm (3))
void addtouser(Strp **pp, const char *string, int rehash)
{
Strp *um;
@ -512,7 +510,6 @@ void addtouser(Strp **pp, const char *string, int rehash)
rehash_chanusers();
}
__attr(CORE_SEG, __regparm (2))
int remfromuser(Strp **pp, const char *string)
{
Strp *um;
@ -532,21 +529,6 @@ int remfromuser(Strp **pp, const char *string)
return(FALSE);
}
/*
* duplicate a list of Strp
*/
void dupe_strp(Strp *sp, Strp **pp)
{
while(sp)
{
set_mallocdoer(dupe_strp);
*pp = (Strp*)Calloc(sizeof(Strp) + strlen(sp->p));
Strcpy((*pp)->p,sp->p);
pp = &((*pp)->next);
sp = sp->next;
}
}
/*
* make duplicates of a user on other local bots
*/
@ -762,7 +744,7 @@ User *add_user(char *handle, char *pass, int axs)
#endif /* DEBUG */
set_mallocdoer(add_user);
user = (User*)Calloc(sizeof(User) + Strlen(handle,pass,NULL)); // Strlen() tolerates pass being NULL, Strlen2() does not.
user = (User*)Calloc(sizeof(User) + StrlenX(handle,pass,NULL)); // StrlenX() tolerates pass being NULL, Strlen2() does not.
user->x.x.access = axs;
user->next = current->userlist;
current->userlist = user;
@ -927,7 +909,6 @@ int get_protaction(Chan *chan, char *userhost)
return(prot);
}
__attr(CORE_SEG, __regparm (2))
int usercanmodify(const char *from, const User *user)
{
User *u;