From 975f98aa822f8191d3e5f0798e068064dd260b9a Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 9 Oct 2003 19:41:09 +0000 Subject: [PATCH] Check the invite/ban string whether we already have it before processing it. --- CHANGES | 5 ++++ TODO | 8 ++++-- apps/silcd/server_util.c | 59 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index e70cca5a..ab922b39 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Thu Oct 9 20:24:09 EEST 2003 Pekka Riikonen + + * Check that a string is not already part on invite/ban + string when processing it. Affected file silcd/server_util.c. + Thu Oct 9 12:06:40 CEST 2003 Pekka Riikonen * Fixed the CUMODE_CHANGE for founder mode changes to comply diff --git a/TODO b/TODO index ff8a28cb..7c7fa709 100644 --- a/TODO +++ b/TODO @@ -14,14 +14,16 @@ TODO for SILC Server 1.0 - test all resume error cases for backup router - test all resume error cases for normal server - test all resume error cases for primary router - - test communication - NOTIFYS (works) - + - Notifys (works) JOIN, TOPIC_SET, CMODE_CHANGE, CUMODE_CHANGE, CHANNEL_CHANGE, UMODE_CHANGE, INVITE, BAN (rest of the notifys does not apply, no testing required) + - Communication + - Test communication during switching, after switching, during + resuming and after resuming. + o Testing diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index fd79ade6..8e540867 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -1836,11 +1836,57 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, tmp2 = silc_calloc(1, sizeof(*tmp2)); silc_hash_table_add(list, (void *)1, tmp2); } - if (tmp[len - 1] == ',') - tmp[len - 1] = '\0'; - if (len) { - silc_buffer_strformat(tmp2, tmp, SILC_STR_END); - silc_buffer_strformat(tmp2, ",", SILC_STR_END); + + /* Check that the string is not part of invite string already */ + if (action == 0x00) { + if (silc_string_match(tmp2->data, tmp)) + break; + + if (len) { + if (tmp[len - 1] == ',') + tmp[len - 1] = '\0'; + silc_buffer_strformat(tmp2, tmp, SILC_STR_END); + silc_buffer_strformat(tmp2, ",", SILC_STR_END); + } + } else { + /* Announced list. Check each entry in the list */ + unsigned char e[256]; + char *start, *end, *n, *rtmp; + int i, k; + + rtmp = silc_memdup(tmp, len); + for (i = 0, k = 0; i < len; i++) { + if (tmp[i] != ',') + continue; + + memset(e, 0, sizeof(e)); + silc_strncat(e, sizeof(e), tmp + k, i - k); + if (!silc_string_match(tmp2->data, e)) { + k = i + 1; + continue; + } + + /* Matches. Delete it since we have it already */ + start = strstr(rtmp, e); + if (start && strlen(start) >= (i - k)) { + end = start + (i - k); + n = silc_calloc(strlen(rtmp) - (i - k), sizeof(*n)); + strncat(n, rtmp, start - rtmp); + if (strlen(end) > 1) + strncat(n, end + 1, ((rtmp + strlen(rtmp)) - end) - 1); + silc_free(rtmp); + rtmp = n; + } + + k = i + 1; + } + + /* Save the part that we didn't already have. */ + if (strlen(rtmp) > 1) { + silc_buffer_strformat(tmp2, rtmp, SILC_STR_END); + silc_buffer_strformat(tmp2, ",", SILC_STR_END); + } + silc_free(rtmp); } } else if (type == 2) { @@ -1911,7 +1957,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, end = start + len; n = silc_calloc(strlen(string) - len, sizeof(*n)); strncat(n, string, start - string); - strncat(n, end + 1, ((string + strlen(string)) - end) - 1); + if (strlen(end) > 1) + strncat(n, end + 1, ((string + strlen(string)) - end) - 1); silc_free(tmp2->head); silc_buffer_set(tmp2, n, strlen(n)); } -- 2.24.0