about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2006-11-20 19:32:07 +0000
committerFlorian Westphal <fw@strlen.de>2006-11-20 19:32:07 +0000
commita09034563aa46d99a4d061d182e15e12cc393efd (patch)
treeee851c004194fbfbce750dbe98b449b8d6de77c6 /src
parent5b35b101f2c5a208c94840e3b020f50d8c91b64f (diff)
downloadngircd-a09034563aa46d99a4d061d182e15e12cc393efd.tar.gz
ngircd-a09034563aa46d99a4d061d182e15e12cc393efd.zip
predefined channels MUST start with '#', but this is not very intuitive,
since # is also used as a comment character in ngircd.conf. Thus
we prefix the name with '#' if it is missing.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index b54c3f15..7390f224 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.95 2006/11/10 10:05:08 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.96 2006/11/20 19:32:07 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -922,6 +922,21 @@ Handle_SERVER( int Line, char *Var, char *Arg )
 } /* Handle_SERVER */
 
 
+static bool
+Handle_Channelname(size_t chancount, const char *name)
+{
+	size_t size = sizeof( Conf_Channel[chancount].name );
+	char *dest = Conf_Channel[chancount].name;
+
+	if (*name && *name != '#') {
+		*dest = '#';
+		--size;
+		++dest;
+	}
+	return size > strlcpy(dest, name, size);
+}
+
+
 static void
 Handle_CHANNEL( int Line, char *Var, char *Arg )
 {
@@ -935,9 +950,7 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
 		chancount = Conf_Channel_Count - 1;
 
 	if( strcasecmp( Var, "Name" ) == 0 ) {
-		/* Name of the channel */
-		len = strlcpy( Conf_Channel[chancount].name, Arg, sizeof( Conf_Channel[chancount].name ));
-		if (len >= sizeof( Conf_Channel[chancount].name ))
+		if (!Handle_Channelname(chancount, Arg))
 			Config_Error_TooLong( Line, Var );
 		return;
 	}