From efa61e7ec08c6902f9259dca043056f0d931e4aa Mon Sep 17 00:00:00 2001 From: codemastr Date: Sun, 29 Dec 2002 17:34:51 +0000 Subject: [PATCH] Fixed a bug in the binary searching routines --- Changes | 2 ++ src/s_conf.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index a858f4e68..7c55341d8 100644 --- a/Changes +++ b/Changes @@ -1747,3 +1747,5 @@ seen. gmtime warning still there h. (#0000556) - Added a pretty_time_val function, this converts a number such as 86400 to "1 day" to make it easier to read. +- Fixed a bug in the binary search functions that could cause crashes when unknown config + directives were added. Reported by 1of10 (#0000587) diff --git a/src/s_conf.c b/src/s_conf.c index 93d89ddc5..53d0a6075 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -947,7 +947,7 @@ void config_progress(char *format, ...) ConfigCommand *config_binary_search(char *cmd) { int start = 0; - int stop = sizeof(_ConfigCommands)/sizeof(_ConfigCommands[0]); + int stop = sizeof(_ConfigCommands)/sizeof(_ConfigCommands[0])-1; int mid; while (start <= stop) { mid = (start+stop)/2; @@ -1556,10 +1556,11 @@ int config_run() OperFlag *config_binary_flags_search(OperFlag *table, char *cmd, int size) { int start = 0; - int stop = size; + int stop = size-1; int mid; while (start <= stop) { mid = (start+stop)/2; + if (smycmp(cmd,table[mid].name) < 0) { stop = mid-1; } @@ -4164,6 +4165,7 @@ int _test_log(ConfigFile *conf, ConfigEntry *ce) { config_error("%s:%i: unknown log flag '%s'", cepp->ce_fileptr->cf_filename, cepp->ce_varlinenum, cepp->ce_varname); + errors++; } }