From 4f2b9a4fd1884852dfecf4855299787fe0553cc8 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Tue, 12 Apr 2016 09:43:50 -0500 Subject: [PATCH] Don't use key member of dictionary iter objects after deletion --- include/authproc.h | 1 + ircd/authproc.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/authproc.h b/include/authproc.h index 00de574a..fa3efab3 100644 --- a/include/authproc.h +++ b/include/authproc.h @@ -32,6 +32,7 @@ struct BlacklistStats { + char *host; uint8_t iptype; unsigned int hits; }; diff --git a/ircd/authproc.c b/ircd/authproc.c index 945da803..77ef669f 100644 --- a/ircd/authproc.c +++ b/ircd/authproc.c @@ -562,6 +562,7 @@ add_blacklist(const char *host, const char *reason, uint8_t iptype, rb_dlink_lis if(s) filterbuf[s - 1] = '\0'; + stats->host = rb_strdup(host); stats->iptype = iptype; stats->hits = 0; rb_dictionary_add(bl_stats, host, stats); @@ -577,6 +578,7 @@ del_blacklist(const char *host) if(stats != NULL) { rb_dictionary_delete(bl_stats, host); + rb_free(stats->host); rb_free(stats); } @@ -592,8 +594,9 @@ del_blacklist_all(void) RB_DICTIONARY_FOREACH(stats, &iter, bl_stats) { + rb_dictionary_delete(bl_stats, stats->host); + rb_free(stats->host); rb_free(stats); - rb_dictionary_delete(bl_stats, iter.cur->key); } rb_helper_write(authd_helper, "O rbl_del_all");