From 5daa5216acad5ff8096f6e42859e3ca22deaa396 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 22 Dec 2008 16:17:17 +0000 Subject: [PATCH] - Added some countermeasures against crash-on-boot, #0003725 and #0003653, reported by Ablom2008 and mist26. --- Changes | 2 ++ src/s_conf.c | 4 +++- src/s_misc.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 1cdc6c265..0fe7701d4 100644 --- a/Changes +++ b/Changes @@ -1691,3 +1691,5 @@ - Fix NAMES with UHNAMES support, screwed it up at 'Win32 compile fixes' a few lines up... - Fix OOB read caused by UHNAMES support. +- Added some countermeasures against crash-on-boot, #0003725 and #0003653, + reported by Ablom2008 and mist26. diff --git a/src/s_conf.c b/src/s_conf.c index a1d4dd239..ff18e3f8f 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1599,6 +1599,8 @@ char *encoded; } encoded = unreal_encodespace(SPAMFILTER_BAN_REASON); + if (!encoded) + abort(); /* hack to trace 'impossible' bug... */ for (tk = tklines[tkl_hash('q')]; tk; tk = tk->next) { if (tk->type != TKL_NICK) @@ -5610,7 +5612,7 @@ int _conf_spamfilter(ConfigFile *conf, ConfigEntry *ce) nl->ptr.spamf = unreal_buildspamfilter(word); nl->ptr.spamf->action = action; - if (has_reason) + if (has_reason && reason) nl->ptr.spamf->tkl_reason = strdup(unreal_encodespace(reason)); else nl->ptr.spamf->tkl_reason = strdup(""); diff --git a/src/s_misc.c b/src/s_misc.c index 84806e7a9..087864233 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -1073,6 +1073,10 @@ static char buf[512], *i, *o; char *unreal_encodespace(char *s) { static char buf[512], *i, *o; + + if (!s) + return NULL; /* NULL in = NULL out */ + for (i = s, o = buf; (*i) && (o < buf+509); i++) { if (*i == ' ')