From 67695c7ad964f0928eb8a74540bb51cca7606389 Mon Sep 17 00:00:00 2001 From: joonicks Date: Thu, 22 Mar 2018 16:43:20 +0100 Subject: [PATCH 1/4] crash in bigsay (#20) * crash in bigsay --- VERSIONS | 1 + src/toybox.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/VERSIONS b/VERSIONS index cb38f74..1ba2bab 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,6 @@ 3.0.99p4 -- WORK IN PROGRESS (~March, 2018) + * Fixed: Crash bug in BIGSAY * Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG * Added: New command: CRASH, for debugging/development... * Changed: configure now defaults to optimizing for code size. diff --git a/src/toybox.c b/src/toybox.c index 3890e9a..76285d2 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -1,7 +1,7 @@ /* EnergyMech, IRC bot software - Copyright (c) 2000-2004 proton + Copyright (c) 2000-2018 proton 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 @@ -199,7 +199,7 @@ void do_bigsay(COMMAND_ARGS) BigC *bigc; Strp *sp; char output[MSGLEN]; - char *pt,*tail,*temp; + char *pt,*tail,*temp,*temp2; int i,x,sz; #ifdef DEBUG @@ -214,6 +214,7 @@ void do_bigsay(COMMAND_ARGS) return; } +#define OEND (output + MSGLEN - 1) for(i=0;idata; for(x=0;xnext; - temp = Strcat(tail,sp->p); - while(temp < (tail + bigc->width)) - *(temp++) = ' '; + temp = sp->p; + temp2 = tail; + while(*temp && tail < OEND) + *(tail++) = *(temp++); + //temp = Strcat(tail,sp->p); + while(tail < (temp2 + bigc->width) && tail < OEND) + *(tail++) = ' '; if (pt[1]) { x = kerning; - while(x--) - *(temp++) = ' '; + while(x-- && tail < OEND) + *(tail++) = ' '; } - *temp = 0; - tail = temp; + *tail = 0; break; } } From 978c11d2ad0f7e90a0df9e87004909614f9f6cc5 Mon Sep 17 00:00:00 2001 From: joonicks Date: Thu, 22 Mar 2018 17:14:48 +0100 Subject: [PATCH 2/4] bigchars vx (#21) * bigchars vx --- default.bigchars | 55 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/default.bigchars b/default.bigchars index bd796d5..7fafbcf 100644 --- a/default.bigchars +++ b/default.bigchars @@ -128,10 +128,10 @@ chars jJ | | | | | `. -/~\__| | +,~.__| | \ | \ | - `~~~~~~´ + `~~~~~~' chars kK ,---, ,-. @@ -154,24 +154,24 @@ chars lL `~~~~~~`/ chars mM -,---, ,---, -| \ / | -| \/ | -| |\ /| | -| | \/ | | -| | | | -| | | | -`---' `---' +,--, ,---, +| \ / | +| \/ | +| |\ /| | +| | \/ | | +| | | | +| | | | +`--' `---' chars nN -,---, ,---, -| \ | | -| \ | | -| |\ \| | -| | \ | -| | \ | -| | | | -`---' `---' +,--, ,---, +| \ | | +| \ | | +| |\ \| | +| | \ | +| | \ | +| | | | +`--' `---' chars oO ,------, @@ -233,6 +233,16 @@ chars uU `\ | `~~~~\/ +chars vV +,. ,--. +| \ | | +| \ | | +`\ \ | | + \ \| | + \ ` | + \ / + `~' + chars wW ,-. ,-, / | | | @@ -243,6 +253,15 @@ chars wW `\ /\ | `~~' `~\/ +chars xX +,--. ,-. +\ \ / / + \ \/ / + ) ( + / /\ \ +/ / \ \ +`-' `--' + chars yY , ,-. /| | \ From 02aab284297b8b4b64260d899cb933c888dc03ec Mon Sep 17 00:00:00 2001 From: joonicks Date: Sat, 24 Mar 2018 01:57:18 +0100 Subject: [PATCH 3/4] read_userlist debug (#22) * read_userlist debug --- src/user.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/user.c b/src/user.c index 963cca6..9e7eaeb 100644 --- a/src/user.c +++ b/src/user.c @@ -298,22 +298,34 @@ int read_userlist(char *filename) int r; #endif +#ifdef DEBUG + if (!filename) + { + 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) + { + debug("(read_userlist) %s: unsafe filename (%i)...\n",filename,r); + return(FALSE); + } + if ((in = open(filename,O_RDONLY)) < 0) + { + debug("(read_userlist) failed to open \"%s\": %s\n",filename,strerror(errno)); + return(FALSE); + } +#else if (!filename) return(FALSE); if (*filename == '<') // read only userfile filename++; -#ifdef DEBUG - if ((r = is_safepath(filename,FILE_MUST_EXIST)) != FILE_IS_SAFE) - { - debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r); - return(FALSE); - } -#else if (is_safepath(filename,FILE_MUST_EXIST) != FILE_IS_SAFE) return(FALSE); -#endif if ((in = open(filename,O_RDONLY)) < 0) return(FALSE); +#endif olduserlist = current->userlist; cfgUser = current->userlist = NULL; @@ -369,23 +381,20 @@ int write_userlist(char *filename) if (!current->ul_save) return(TRUE); - if (*filename == '<') // we dont write to read only userfiles #ifdef DEBUG + if (*filename == '<') // we dont write to read only userfiles { debug("(write_userlist) %s: writing to read only userfile is prohibited...\n",filename); return(FALSE); } -#else - return(FALSE); -#endif - -#ifdef DEBUG if ((r = is_safepath(filename,FILE_MAY_EXIST)) != FILE_IS_SAFE) { debug("(write_userlist) %s: unsafe filename (%i)...\n",filename,r); return(FALSE); } #else + if (*filename == '<') // we dont write to read only userfiles + return(FALSE); if (is_safepath(filename,FILE_MAY_EXIST) != FILE_IS_SAFE) return(FALSE); #endif From deb92cb01a95621ab91a8c6d5ece62fa72069043 Mon Sep 17 00:00:00 2001 From: joonicks Date: Mon, 26 Mar 2018 00:43:24 +0200 Subject: [PATCH 4/4] urlcap crashfix (#23) * url crash fix --- configure | 20 ++++++------ src/auth.c | 1 - src/channel.c | 6 ---- src/core.c | 2 +- src/debug.c | 1 + src/function.c | 89 ++++++++++++++++++++++++++++++++++++-------------- src/greet.c | 2 +- src/h.h | 9 ++++- src/help.c | 1 - src/irc.c | 2 +- src/kicksay.c | 2 +- src/net.c | 6 ++-- src/note.c | 18 ++-------- src/notify.c | 2 +- src/python.c | 4 +-- src/redirect.c | 2 +- src/seen.c | 4 +-- src/shit.c | 2 +- src/socket.c | 2 +- src/text.h | 2 +- src/toybox.c | 8 +---- src/trivia.c | 10 +----- src/uptime.c | 2 +- src/urlcap.c | 21 ++++-------- src/user.c | 21 +----------- 25 files changed, 111 insertions(+), 128 deletions(-) diff --git a/configure b/configure index f9da0ed..bc5f9a2 100755 --- a/configure +++ b/configure @@ -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 diff --git a/src/auth.c b/src/auth.c index 0ccb914..141bc40 100644 --- a/src/auth.c +++ b/src/auth.c @@ -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; diff --git a/src/channel.c b/src/channel.c index 6402d9e..178b9ce 100644 --- a/src/channel.c +++ b/src/channel.c @@ -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; diff --git a/src/core.c b/src/core.c index b650a44..49bb26b 100644 --- a/src/core.c +++ b/src/core.c @@ -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) diff --git a/src/debug.c b/src/debug.c index 016f212..969446f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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" }, diff --git a/src/function.c b/src/function.c index 675a4d3..d1e09db 100644 --- a/src/function.c +++ b/src/function.c @@ -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(;origp,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; diff --git a/src/greet.c b/src/greet.c index 4e3132b..bdd23f7 100644 --- a/src/greet.c +++ b/src/greet.c @@ -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; */ } diff --git a/src/h.h b/src/h.h index 8cb1050..f6ae3e8 100644 --- a/src/h.h +++ b/src/h.h @@ -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)); diff --git a/src/help.c b/src/help.c index 49ab4c7..9d08033 100644 --- a/src/help.c +++ b/src/help.c @@ -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; diff --git a/src/irc.c b/src/irc.c index 4a6efdb..97996c5 100644 --- a/src/irc.c +++ b/src/irc.c @@ -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; diff --git a/src/kicksay.c b/src/kicksay.c index e956607..c862eba 100644 --- a/src/kicksay.c +++ b/src/kicksay.c @@ -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; diff --git a/src/net.c b/src/net.c index 40ee24e..05453fe 100644 --- a/src/net.c +++ b/src/net.c @@ -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; diff --git a/src/note.c b/src/note.c index 302f5e4..a060953 100644 --- a/src/note.c +++ b/src/note.c @@ -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) diff --git a/src/notify.c b/src/notify.c index f2b7751..29c676d 100644 --- a/src/notify.c +++ b/src/notify.c @@ -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) { diff --git a/src/python.c b/src/python.c index 39ae745..bc8afcb 100644 --- a/src/python.c +++ b/src/python.c @@ -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 diff --git a/src/redirect.c b/src/redirect.c index 9aec244..28aa9c5 100644 --- a/src/redirect.c +++ b/src/redirect.c @@ -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); } diff --git a/src/seen.c b/src/seen.c index 40009ab..d26379d 100644 --- a/src/seen.c +++ b/src/seen.c @@ -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; diff --git a/src/shit.c b/src/shit.c index a5023b2..3a30499 100644 --- a/src/shit.c +++ b/src/shit.c @@ -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; diff --git a/src/socket.c b/src/socket.c index 7fd2633..45e5f6a 100644 --- a/src/socket.c +++ b/src/socket.c @@ -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); } diff --git a/src/text.h b/src/text.h index ce01396..c99dac0 100644 --- a/src/text.h +++ b/src/text.h @@ -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)" diff --git a/src/toybox.c b/src/toybox.c index 76285d2..de6d5d5 100644 --- a/src/toybox.c +++ b/src/toybox.c @@ -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); } diff --git a/src/trivia.c b/src/trivia.c index aa28ac5..f969b69 100644 --- a/src/trivia.c +++ b/src/trivia.c @@ -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; diff --git a/src/uptime.c b/src/uptime.c index 9bfcaa8..f584146 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -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; diff --git a/src/urlcap.c b/src/urlcap.c index bb4b294..d0bb823 100644 --- a/src/urlcap.c +++ b/src/urlcap.c @@ -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; diff --git a/src/user.c b/src/user.c index 9e7eaeb..a893e6a 100644 --- a/src/user.c +++ b/src/user.c @@ -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;