From 0b5ea4f865da8056ea09e1aca2e7e9c89ed416a6 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 22 Jan 2010 01:41:48 +0100 Subject: [PATCH 1/9] Fix include/serno.h generation. Apparently #value# is no longer special in hg templates. --- scripts/application.sh | 2 +- scripts/makerelease.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/application.sh b/scripts/application.sh index 203bb6406..d97fef170 100755 --- a/scripts/application.sh +++ b/scripts/application.sh @@ -25,7 +25,7 @@ if [ "x$TIP" = "x" ]; then fi # Charybdis wants the hg tip to be in include/serno.h, in its own format. -MYTIP=`hg parents --template '#date|shortdate#_#node|short#' 2>/dev/null | sed -e s/-//g -e s/_/-/` +MYTIP=`hg parents --template '{date|shortdate}_{node|short}' 2>/dev/null | sed -e s/-//g -e s/_/-/` echo "[charybdis] Generating include/serno.h for tip $MYTIP." cat << _EOF_ > include/serno.h /* Generated automatically by makepackage. Any changes made here will be lost. */ diff --git a/scripts/makerelease.sh b/scripts/makerelease.sh index 209ff697d..7b3fc2769 100755 --- a/scripts/makerelease.sh +++ b/scripts/makerelease.sh @@ -30,7 +30,7 @@ if [ "x$2" = "x--automatic" ]; then AUTOMATIC="yes" fi -TIP=`hg tip --template "#rev#:#node|short#"` +TIP=`hg parents --template "{rev}:{node|short}"` WRKDIR=`pwd` From cd5d9abf632a6de53c156b5e4762a8e56ef661a0 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 22 Jan 2010 02:02:45 +0100 Subject: [PATCH 2/9] Do not read in help files starting with a dot (including dot and dot-dot). --- src/cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cache.c b/src/cache.c index c8210504f..eb4ca6d9d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -253,6 +253,8 @@ load_help(void) while((ldirent = readdir(helpfile_dir)) != NULL) { + if(ldirent->d_name[0] == '.') + continue; rb_snprintf(filename, sizeof(filename), "%s/%s", HPATH, ldirent->d_name); cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER); irc_dictionary_add(help_dict_oper, cacheptr->name, cacheptr); @@ -266,6 +268,8 @@ load_help(void) while((ldirent = readdir(helpfile_dir)) != NULL) { + if(ldirent->d_name[0] == '.') + continue; rb_snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name); #if defined(S_ISLNK) && defined(HAVE_LSTAT) From 1fd171a547032ae8a6d906d1eccdfdb329115ca2 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 24 Jan 2010 19:37:00 +0100 Subject: [PATCH 3/9] Fix op-moderate (cmode +z) for channel names with '@'. --- modules/core/m_message.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 3f814f658..66ddaced1 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -392,12 +392,6 @@ build_target_list(int p_or_n, const char *command, struct Client *client_p, continue; } - if(strchr(nick, '@') || (IsOper(source_p) && (*nick == '$'))) - { - handle_special(p_or_n, command, client_p, source_p, nick, text); - continue; - } - if(IsServer(client_p) && *nick == '=' && nick[1] == '#') { nick++; @@ -424,6 +418,12 @@ build_target_list(int p_or_n, const char *command, struct Client *client_p, continue; } + if(strchr(nick, '@') || (IsOper(source_p) && (*nick == '$'))) + { + handle_special(p_or_n, command, client_p, source_p, nick, text); + continue; + } + /* no matching anything found - error if not NOTICE */ if(p_or_n != NOTICE) { From 114105b42943698b8d23861d3f4385cf9e98efac Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 27 Jan 2010 21:05:10 +0100 Subject: [PATCH 4/9] Fix /links buffer overflow. --- modules/m_links.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/m_links.c b/modules/m_links.c index 3aafbc7f2..bc28ad8bc 100644 --- a/modules/m_links.c +++ b/modules/m_links.c @@ -87,6 +87,8 @@ mo_links(struct Client *client_p, struct Client *source_p, int parc, const char if(parc > 2) { + if(strlen(parv[2]) > HOSTLEN) + return 0; if(hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv) != HUNTED_ISME) return 0; @@ -138,19 +140,21 @@ clean_string(char *dest, const unsigned char *src, size_t len) if(dest == NULL || src == NULL) return NULL; - len -= 3; /* allow for worst case, '^A\0' */ - - while (*src && (len > 0)) + while (*src && (len > 1)) { if(*src & 0x80) /* if high bit is set */ { *d++ = '.'; --len; + if(len <= 1) + break; } else if(!IsPrint(*src)) /* if NOT printable */ { *d++ = '^'; --len; + if(len <= 1) + break; *d++ = 0x40 + *src; /* turn it into a printable */ } else From 8f103562177a59758d4d12069ac6bfe805a22537 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 30 Jan 2010 15:57:10 +0100 Subject: [PATCH 5/9] Remove remnants of _t typedefs. --- include/client.h | 54 +++++++++++++++++------------------------------- src/client.c | 6 +++--- src/listener.c | 30 +++++++++++++-------------- 3 files changed, 37 insertions(+), 53 deletions(-) diff --git a/include/client.h b/include/client.h index 13bd09665..508b9db25 100644 --- a/include/client.h +++ b/include/client.h @@ -69,22 +69,6 @@ struct PreClient; struct ListClient; struct scache_entry; -/* - * Atheme's coding standards require that we use BSD-style user-defined types - * for stuff. Fun! --nenolod - */ -typedef struct User user_t; -typedef struct Server server_t; -typedef struct Client client_t; -typedef struct LocalUser local_user_t; -typedef struct Listener listener_t; -typedef struct DNSReply dns_reply_t; -typedef struct Whowas whowas_entry_t; -typedef struct ConfItem conf_item_t; -typedef struct AuthRequest auth_request_t; -typedef struct PreClient pre_client_t; -typedef struct ListClient list_client_t; - /* * Client structures */ @@ -100,7 +84,7 @@ struct User struct Server { - user_t *user; /* who activated this connection */ + struct User *user; /* who activated this connection */ char by[NICKLEN]; rb_dlink_list servers; rb_dlink_list users; @@ -123,12 +107,12 @@ struct Client { rb_dlink_node node; rb_dlink_node lnode; - user_t *user; /* ...defined, if this is a User */ - server_t *serv; /* ...defined, if this is a server */ - client_t *servptr; /* Points to server this Client is on */ - client_t *from; /* == self, if Local Client, *NEVER* NULL! */ + struct User *user; /* ...defined, if this is a User */ + struct Server *serv; /* ...defined, if this is a server */ + struct Client *servptr; /* Points to server this Client is on */ + struct Client *from; /* == self, if Local Client, *NEVER* NULL! */ - whowas_entry_t *whowas; /* Pointers to whowas structs */ + struct Whowas *whowas; /* Pointers to whowas structs */ time_t tsinfo; /* TS on the nick, SVINFO on server */ unsigned int umodes; /* opers, normal users subset */ unsigned int flags; /* client flags */ @@ -173,8 +157,8 @@ struct Client int received_number_of_privmsgs; int flood_noticed; - local_user_t *localClient; - pre_client_t *preClient; + struct LocalUser *localClient; + struct PreClient *preClient; time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */ }; @@ -219,8 +203,8 @@ struct LocalUser unsigned int receiveK; /* Statistics: total k-bytes received */ unsigned short sendB; /* counters to count upto 1-k lots of bytes */ unsigned short receiveB; /* sent and received. */ - listener_t *listener; /* listener accepted from */ - conf_item_t *att_conf; /* attached conf */ + struct Listener *listener; /* listener accepted from */ + struct ConfItem *att_conf; /* attached conf */ struct server_conf *att_sconf; struct rb_sockaddr_storage ip; @@ -267,14 +251,14 @@ struct LocalUser int sent_parsed; /* how many messages we've parsed in this second */ time_t last_knock; /* time of last knock */ unsigned long random_ping; - auth_request_t *auth_request; + struct AuthRequest *auth_request; /* target change stuff */ uint32_t targets[10]; /* targets were aware of (fnv32(use_id(target_p))) */ unsigned int targinfo[2]; /* cyclic array, no in use */ time_t target_last; /* last time we cleared a slot */ - list_client_t *safelist_data; + struct ListClient *safelist_data; char *mangledhost; /* non-NULL if host mangling module loaded and applicable to this client */ @@ -570,7 +554,7 @@ extern const char *get_client_name(struct Client *client, int show_ip); extern const char *log_client_name(struct Client *, int); extern int is_remote_connect(struct Client *); extern void init_client(void); -extern client_t *make_client(struct Client *from); +extern struct Client *make_client(struct Client *from); extern void free_pre_client(struct Client *client); extern void free_client(struct Client *client); @@ -583,10 +567,10 @@ extern void error_exit_client(struct Client *, int); extern void count_local_client_memory(size_t * count, size_t * memory); extern void count_remote_client_memory(size_t * count, size_t * memory); -extern client_t *find_chasing(struct Client *, const char *, int *); -extern client_t *find_person(const char *); -extern client_t *find_named_person(const char *); -extern client_t *next_client(struct Client *, const char *); +extern struct Client *find_chasing(struct Client *, const char *, int *); +extern struct Client *find_person(const char *); +extern struct Client *find_named_person(const char *); +extern struct Client *next_client(struct Client *, const char *); #define accept_message(s, t) ((s) == (t) || (rb_dlinkFind((s), &((t)->localClient->allow_list)))) extern void del_all_accepts(struct Client *client_p); @@ -597,8 +581,8 @@ extern int show_ip_conf(struct ConfItem *aconf, struct Client *target_p); extern void initUser(void); extern void free_user(struct User *, struct Client *); -extern user_t *make_user(struct Client *); -extern server_t *make_server(struct Client *); +extern struct User *make_user(struct Client *); +extern struct Server *make_server(struct Client *); extern void close_connection(struct Client *); extern void init_uid(void); extern char *generate_uid(void); diff --git a/src/client.c b/src/client.c index 72ce398b5..0ad24c639 100644 --- a/src/client.c +++ b/src/client.c @@ -1670,14 +1670,14 @@ make_user(struct Client *client_p) * side effects - add's an Server information block to a client * if it was not previously allocated. */ -server_t * +struct Server * make_server(struct Client *client_p) { - server_t *serv = client_p->serv; + struct Server *serv = client_p->serv; if(!serv) { - serv = (server_t *) rb_malloc(sizeof(server_t)); + serv = (struct Server *) rb_malloc(sizeof(struct Server)); client_p->serv = serv; } return client_p->serv; diff --git a/src/listener.c b/src/listener.c index 9e03c12dd..489aee7ec 100644 --- a/src/listener.c +++ b/src/listener.c @@ -52,14 +52,14 @@ static const struct in6_addr in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }; #endif -static listener_t *ListenerPollList = NULL; +static struct Listener *ListenerPollList = NULL; static int accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, void *data); static void accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t addrlen, void *data); -static listener_t * +static struct Listener * make_listener(struct rb_sockaddr_storage *addr) { - listener_t *listener = (listener_t *) rb_malloc(sizeof(listener_t)); + struct Listener *listener = (struct Listener *) rb_malloc(sizeof(struct Listener)); s_assert(0 != listener); listener->name = me.name; listener->F = NULL; @@ -70,7 +70,7 @@ make_listener(struct rb_sockaddr_storage *addr) } void -free_listener(listener_t *listener) +free_listener(struct Listener *listener) { s_assert(NULL != listener); if(listener == NULL) @@ -82,7 +82,7 @@ free_listener(listener_t *listener) ListenerPollList = listener->next; else { - listener_t *prev = ListenerPollList; + struct Listener *prev = ListenerPollList; for (; prev; prev = prev->next) { if(listener == prev->next) @@ -104,7 +104,7 @@ free_listener(listener_t *listener) * returns "host.foo.org:6667" for a given listener */ const char * -get_listener_name(const listener_t *listener) +get_listener_name(const struct Listener *listener) { static char buf[HOSTLEN + HOSTLEN + PORTNAMELEN + 4]; int port = 0; @@ -133,7 +133,7 @@ get_listener_name(const listener_t *listener) void show_ports(struct Client *source_p) { - listener_t *listener = 0; + struct Listener *listener = 0; for (listener = ListenerPollList; listener; listener = listener->next) { @@ -165,7 +165,7 @@ show_ports(struct Client *source_p) #endif static int -inetport(listener_t *listener) +inetport(struct Listener *listener) { rb_fde_t *F; int ret; @@ -245,11 +245,11 @@ inetport(listener_t *listener) return 1; } -static listener_t * +static struct Listener * find_listener(struct rb_sockaddr_storage *addr) { - listener_t *listener = NULL; - listener_t *last_closed = NULL; + struct Listener *listener = NULL; + struct Listener *last_closed = NULL; for (listener = ListenerPollList; listener; listener = listener->next) { @@ -307,7 +307,7 @@ find_listener(struct rb_sockaddr_storage *addr) void add_listener(int port, const char *vhost_ip, int family, int ssl) { - listener_t *listener; + struct Listener *listener; struct rb_sockaddr_storage vaddr; /* @@ -389,7 +389,7 @@ add_listener(int port, const char *vhost_ip, int family, int ssl) * close_listener - close a single listener */ void -close_listener(listener_t *listener) +close_listener(struct Listener *listener) { s_assert(listener != NULL); if(listener == NULL) @@ -414,8 +414,8 @@ close_listener(listener_t *listener) void close_listeners() { - listener_t *listener; - listener_t *listener_next = 0; + struct Listener *listener; + struct Listener *listener_next = 0; /* * close all 'extra' listening ports we have */ From fcb057992c58e13781f60c6ccd618cdb9a4062ff Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 31 Jan 2010 01:29:08 +0100 Subject: [PATCH 6/9] Fix memory leak with auth_user. from ircd-seven (spb) --- src/client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.c b/src/client.c index 0ad24c639..93b04e717 100644 --- a/src/client.c +++ b/src/client.c @@ -224,6 +224,13 @@ free_local_client(struct Client *client_p) rb_close(client_p->localClient->F); } + if (client_p->localClient->auth_user) + { + memset(client_p->localClient->auth_user, 0, + strlen(client_p->localClient->auth_user)); + rb_free(client_p->localClient->auth_user); + } + if(client_p->localClient->passwd) { memset(client_p->localClient->passwd, 0, From 90afc118fd9e785eace9e3fac17b061287518d5d Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 31 Jan 2010 01:30:25 +0100 Subject: [PATCH 7/9] No need to be paranoid about clearing auth_user. It is a username, not a password. --- src/client.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/client.c b/src/client.c index 93b04e717..428b799c4 100644 --- a/src/client.c +++ b/src/client.c @@ -224,13 +224,6 @@ free_local_client(struct Client *client_p) rb_close(client_p->localClient->F); } - if (client_p->localClient->auth_user) - { - memset(client_p->localClient->auth_user, 0, - strlen(client_p->localClient->auth_user)); - rb_free(client_p->localClient->auth_user); - } - if(client_p->localClient->passwd) { memset(client_p->localClient->passwd, 0, @@ -238,6 +231,7 @@ free_local_client(struct Client *client_p) rb_free(client_p->localClient->passwd); } + rb_free(client_p->localClient->auth_user); rb_free(client_p->localClient->challenge); rb_free(client_p->localClient->fullcaps); rb_free(client_p->localClient->opername); From 3d1f32c07a4eb21713f2ee2b54481d381e4cd362 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 31 Jan 2010 01:36:37 +0100 Subject: [PATCH 8/9] Take auth_user into account when detecting redundant/duplicate auth{}. from ircd-seven (spb) --- src/newconf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/newconf.c b/src/newconf.c index 12893dd0d..6afb2acad 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -892,7 +892,7 @@ conf_begin_auth(struct TopConf *tc) static int conf_end_auth(struct TopConf *tc) { - struct ConfItem *yy_tmp; + struct ConfItem *yy_tmp, *found_conf; rb_dlink_node *ptr; rb_dlink_node *next_ptr; @@ -910,9 +910,12 @@ conf_end_auth(struct TopConf *tc) collapse(yy_aconf->user); collapse(yy_aconf->host); conf_add_class_to_conf(yy_aconf); - if (find_exact_conf_by_address("*", CONF_CLIENT, "*")) + if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) conf_report_error("Ignoring redundant auth block (after *@*)"); - else if (find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) + else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && + ( (!found_conf->spasswd && !yy_aconf->spasswd) || + (found_conf->spasswd && yy_aconf->spasswd && + 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) conf_report_error("Ignoring duplicate auth block for %s@%s", yy_aconf->user, yy_aconf->host); else From 5f2df25109a42089316f2a62b6abbe2e83a15903 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 31 Jan 2010 01:40:43 +0100 Subject: [PATCH 9/9] Slightly tighten auth{} duplicate check: If the existing auth{} block has no auth_user, it will trump any auth{} block for the same u@h. --- src/newconf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/newconf.c b/src/newconf.c index 6afb2acad..3cf15c6d5 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -913,8 +913,7 @@ conf_end_auth(struct TopConf *tc) if ((found_conf = find_exact_conf_by_address("*", CONF_CLIENT, "*")) && found_conf->spasswd == NULL) conf_report_error("Ignoring redundant auth block (after *@*)"); else if ((found_conf = find_exact_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user)) && - ( (!found_conf->spasswd && !yy_aconf->spasswd) || - (found_conf->spasswd && yy_aconf->spasswd && + (!found_conf->spasswd || (yy_aconf->spasswd && 0 == irccmp(found_conf->spasswd, yy_aconf->spasswd)))) conf_report_error("Ignoring duplicate auth block for %s@%s", yy_aconf->user, yy_aconf->host);