summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2020-06-11 16:45:30 +0200
committerAlexander Barton <alex@barton.de>2020-06-11 16:45:30 +0200
commit07cb8ed9ae14307b7b9335faa957baa340632e57 (patch)
treefcbd528712d0c365768aaa6d5e17d3ef906aedf8 /src
parentb003d469f18c843725de4f6f46b7ca0714e0a984 (diff)
downloadngircd-07cb8ed9ae14307b7b9335faa957baa340632e57.tar.gz
ngircd-07cb8ed9ae14307b7b9335faa957baa340632e57.zip
Don't send invalid CHANINFO commands when no key is set
It can happen that a channel is +k, but no key is set: for example by
misconfiguring a pre-defined channel. In this case, ngIRCd sent an
invalud CHANINFO command ("CHANINFO #test +Pk  0 :'", note the unset
key represented by the two spaces) to its peers.

Fix this and enhance the CHANINFO documentation.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/numeric.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c
index 380b9078..8edb76e2 100644
--- a/src/ngircd/numeric.c
+++ b/src/ngircd/numeric.c
@@ -214,7 +214,7 @@ Synchronize_Lists(CLIENT * Client)
 static bool
 Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
 {
-	char *modes, *topic;
+	char *modes, *topic, *key;
 	bool has_k, has_l;
 
 #ifdef DEBUG
@@ -243,9 +243,10 @@ Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
 					  Channel_Name(Chan), modes, topic);
 	}
 	/* "CHANINFO <chan> +<modes> <key> <limit> :<topic>" */
+	key = Channel_Key(Chan);
 	return IRC_WriteStrClient(Client, "CHANINFO %s +%s %s %lu :%s",
 				  Channel_Name(Chan), modes,
-				  has_k ? Channel_Key(Chan) : "*",
+				  has_k ? (key && *key ? key : "*") : "*",
 				  has_l ? Channel_MaxUsers(Chan) : 0, topic);
 } /* Send_CHANINFO */