From 2498a1b577ac3901abbff2612d3647f8aef038b7 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Thu, 27 May 2010 18:03:51 -0400 Subject: [PATCH] Fix some valgrind warnings. --- extensions/m_oaccept.c | 8 ++++---- extensions/m_okick.c | 4 ++-- modules/core/m_kick.c | 4 ++-- modules/core/m_message.c | 4 ++-- src/channel.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/extensions/m_oaccept.c b/extensions/m_oaccept.c index f0b38ed..f24012b 100644 --- a/extensions/m_oaccept.c +++ b/extensions/m_oaccept.c @@ -23,7 +23,7 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha struct Metadata *md; struct DictionaryIter iter; struct Client *target_p; - char *text = rb_strdup(""); + char text[10]; if(!(target_p = find_client(parv[1]))) { @@ -31,10 +31,10 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha return 0; } - rb_sprintf(text, "O%s", source_p->id); + rb_snprintf(text, sizeof(text), "O%s", source_p->id); - /* Don't allow someone to pointlessly fill up someone's metadata - * with identical OACCEPT entries. */ + /* Provide a nice error message if you try to OACCEPT someone + * who you've already OACCEPTed. */ DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) { if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) diff --git a/extensions/m_okick.c b/extensions/m_okick.c index c09c42a..f373316 100644 --- a/extensions/m_okick.c +++ b/extensions/m_okick.c @@ -68,7 +68,7 @@ mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char char *name; char *p = NULL; char *user; - char *text = rb_strdup(""); + char text[10]; static char buf[BUFSIZE]; if(*parv[2] == '\0') @@ -138,7 +138,7 @@ mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char ":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment); remove_user_from_channel(msptr); - rb_sprintf(text, "K%s", who->id); + rb_snprintf(text, sizeof(text), "K%s", who->id); /* we don't need to track NOREJOIN stuff unless it's our client being kicked */ if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN) diff --git a/modules/core/m_kick.c b/modules/core/m_kick.c index 572e911..3029ca6 100644 --- a/modules/core/m_kick.c +++ b/modules/core/m_kick.c @@ -68,7 +68,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p char *comment; const char *name; char *p = NULL; - char *text = rb_strdup(""); + char text[10]; const char *user; static char buf[BUFSIZE]; int is_override = 0; @@ -235,7 +235,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p use_id(source_p), chptr->chname, use_id(who), comment); remove_user_from_channel(msptr); - rb_sprintf(text, "K%s", who->id); + rb_snprintf(text, sizeof(text), "K%s", who->id); /* we don't need to track NOREJOIN stuff unless it's our client being kicked */ if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN) diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 6e8ba99..df3d97d 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -733,7 +733,7 @@ msg_client(int p_or_n, const char *command, struct Metadata *md; struct DictionaryIter iter; int oaccept = 0; - char *text3 = rb_strdup(""); + char text3[10]; if(MyClient(source_p)) { @@ -796,7 +796,7 @@ msg_client(int p_or_n, const char *command, { if (IsOper(source_p)) { - rb_sprintf(text3, "O%s", source_p->id); + rb_snprintf(text3, sizeof(text3), "O%s", source_p->id); DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) { if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text3)) diff --git a/src/channel.c b/src/channel.c index f30a069..5826892 100644 --- a/src/channel.c +++ b/src/channel.c @@ -826,7 +826,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) char src_host[NICKLEN + USERLEN + HOSTLEN + 6]; char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6]; char src_althost[NICKLEN + USERLEN + HOSTLEN + 6]; - char *text = rb_strdup(""); + char text[10]; int use_althost = 0; int i = 0; hook_data_channel moduledata; @@ -857,7 +857,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN) return (ERR_BANNEDFROMCHAN); - rb_sprintf(text, "K%s", source_p->id); + rb_snprintf(text, sizeof(text), "K%s", source_p->id); DICTIONARY_FOREACH(md, &iter, chptr->metadata) {