From cd7d357a6f2c40c78b2f20b276e49078fd14b3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gomez?= Date: Sun, 4 Feb 2024 23:24:29 +0900 Subject: [PATCH] Fix endless loop on /BIP LIST connections with long on_connect_send MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - when the line to send to IRC was over a specific limit, the code was not moving to the next item in the on_connect_send list after sending the text to the client - this change also adds a hard limit of 10 on_connect_send to display for each connection Signed-off-by: Loïc Gomez --- src/bip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bip.c b/src/bip.c index ff30180..9d241fb 100644 --- a/src/bip.c +++ b/src/bip.c @@ -1331,9 +1331,10 @@ void adm_print_connection(struct link_client *ic, struct link *lnk, bufpos = buf; list_iterator_t itocs; + int i = 0; for (list_it_init(&lnk->on_connect_send, &itocs); - list_it_item(&itocs);) { - bufpos = bip_strcatf_fit(&remaining, bufpos, "%s", + list_it_item(&itocs) && i < 10; i++) { + bufpos = bip_strcatf_fit(&remaining, bufpos, " on_connect_send: %s", (char *)list_it_item(&itocs)); if (!bufpos) { // if oversized, print and reset @@ -1341,6 +1342,7 @@ void adm_print_connection(struct link_client *ic, struct link *lnk, bip_notify(ic, "%s", buf); remaining = LINE_SIZE_LIM; bufpos = buf; + list_it_next(&itocs); continue; } else { // if ok, go to next item