Commit Diff


commit - cde2e8a2775e8b01266627a60a08e2560eac42c8
commit + 3ab00e3a11acfd22741e58aa409bb2026e0665ba
blob - 800e99353647f8758488a30db2d8f41259dc1129
blob + 156f943ef9a318269edb487ccef5c6168af11487
--- src/ngircd/class.c
+++ src/ngircd/class.c
@@ -98,24 +98,30 @@ Class_HandleServerBans(CLIENT *Client)
 
 
 GLOBAL bool
-Class_AddMask(const int Class, const char *Mask, time_t ValidUntil,
+Class_AddMask(const int Class, const char *Pattern, time_t ValidUntil,
 	      const char *Reason)
 {
+	char mask[MASK_LEN];
+
 	assert(Class < CLASS_COUNT);
 	assert(Mask != NULL);
 	assert(Reason != NULL);
 
-	return Lists_Add(&My_Classes[Class], Lists_MakeMask(Mask),
+	Lists_MakeMask(Pattern, mask, sizeof(mask));
+	return Lists_Add(&My_Classes[Class], mask,
 			 ValidUntil, Reason);
 }
 
 GLOBAL void
-Class_DeleteMask(const int Class, const char *Mask)
+Class_DeleteMask(const int Class, const char *Pattern)
 {
+	char mask[MASK_LEN];
+
 	assert(Class < CLASS_COUNT);
 	assert(Mask != NULL);
 
-	Lists_Del(&My_Classes[Class], Lists_MakeMask(Mask));
+	Lists_MakeMask(Pattern, mask, sizeof(mask));
+	Lists_Del(&My_Classes[Class], mask);
 }
 
 GLOBAL struct list_head *
blob - ba2e16069def9e0ad4abb365a97462cef3c46ec9
blob + f118284b8a875cc343791a6672f32919be3a3203
--- src/ngircd/class.h
+++ src/ngircd/class.h
@@ -25,9 +25,9 @@
 GLOBAL void Class_Init PARAMS((void));
 GLOBAL void Class_Exit PARAMS((void));
 
-GLOBAL bool Class_AddMask PARAMS((const int Class, const char *Mask,
+GLOBAL bool Class_AddMask PARAMS((const int Class, const char *Pattern,
 				  const time_t ValidUntil, const char *Reason));
-GLOBAL void Class_DeleteMask PARAMS((const int Class, const char *Mask));
+GLOBAL void Class_DeleteMask PARAMS((const int Class, const char *Pattern));
 
 GLOBAL bool Class_GetMemberReason PARAMS((const int Class, CLIENT *Client,
 					  char *reason, size_t len));
blob - 6b92a699ffa9b0c7c8e57ca9fa05ca9427a5d499
blob + cffbfadfa10cdb8ecca525c8d1c787bd650ee71c
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -50,7 +50,6 @@
 /** Max. length of random salt */
 #define RANDOM_SALT_LEN 32
 
-
 /* Size of structures */
 
 /** Max. count of configurable servers. */
@@ -114,6 +113,9 @@
 /** Max. host name length (including NULL). */
 #define CLIENT_HOST_LEN 64
 
+/** Max. mask lenght (including NULL). */
+#define MASK_LEN (2 * CLIENT_HOST_LEN)
+
 /** Max. length of all client modes (including NULL). */
 #define CLIENT_MODE_LEN 21
 
blob - b5f28fa36d73cc0f3bac75d394d1504c667b79a7
blob + 765de394483b8880b0bdc149e6ef28e46d963991
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -980,7 +980,7 @@ static bool
 Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
 	    const char *Pattern)
 {
-	const char *mask;
+	char mask[MASK_LEN];
 	struct list_head *list = NULL;
 	long int current_count;
 
@@ -989,7 +989,7 @@ Add_To_List(char what, CLIENT *Prefix, CLIENT *Client,
 	assert(Pattern != NULL);
 	assert(what == 'I' || what == 'b' || what == 'e');
 
-	mask = Lists_MakeMask(Pattern);
+	Lists_MakeMask(Pattern, mask, sizeof(mask));
 	current_count = Lists_Count(Channel_GetListInvites(Channel))
 			+ Lists_Count(Channel_GetListExcepts(Channel))
 			+ Lists_Count(Channel_GetListBans(Channel));
@@ -1047,7 +1047,7 @@ static bool
 Del_From_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
 	      const char *Pattern)
 {
-	const char *mask;
+	char mask[MASK_LEN];
 	struct list_head *list = NULL;
 
 	assert(Client != NULL);
@@ -1055,7 +1055,7 @@ Del_From_List(char what, CLIENT *Prefix, CLIENT *Clien
 	assert(Pattern != NULL);
 	assert(what == 'I' || what == 'b' || what == 'e');
 
-	mask = Lists_MakeMask(Pattern);
+	Lists_MakeMask(Pattern, mask, sizeof(mask));
 
 	switch (what) {
 		case 'I':
blob - bab30f221be15766267347cf2a0f9f14ae5e92de
blob + 9ebd89067fb73f2dfa3a07d28924a65ca0f265e4
--- src/ngircd/lists.c
+++ src/ngircd/lists.c
@@ -34,8 +34,6 @@
 #include "exp.h"
 #include "lists.h"
 
-#define MASK_LEN	(2*CLIENT_HOST_LEN)
-
 struct list_elem {
 	struct list_elem *next;	/** pointer to next list element */
 	char mask[MASK_LEN];	/** IRC mask */
@@ -261,18 +259,14 @@ Lists_CheckDupeMask(const struct list_head *h, const c
 
 /**
  * Generate a valid IRC mask from "any" string given.
- *
- * Attention: This mask is only valid until the next call to Lists_MakeMask(),
- * because a single global buffer ist used! You have to copy the generated
- * mask to some sane location yourself!
  *
  * @param Pattern Source string to generate an IRC mask for.
- * @return Pointer to global result buffer.
+ * @param mask    Buffer to store the mask.
+ * @param len     Size of the buffer.
  */
-GLOBAL const char *
-Lists_MakeMask(const char *Pattern)
+GLOBAL void
+Lists_MakeMask(const char *Pattern, char *mask, size_t len)
 {
-	static char TheMask[MASK_LEN];
 	char *excl, *at;
 
 	assert(Pattern != NULL);
@@ -285,30 +279,22 @@ Lists_MakeMask(const char *Pattern)
 
 	if (!at && !excl) {
 		/* Neither "!" nor "@" found: use string as nickname */
-		strlcpy(TheMask, Pattern, sizeof(TheMask) - 5);
-		strlcat(TheMask, "!*@*", sizeof(TheMask));
-		return TheMask;
-	}
-
-	if (!at && excl) {
+		strlcpy(mask, Pattern, len);
+		strlcat(mask, "!*@*", len);
+	} else if (!at && excl) {
 		/* Domain part is missing */
-		strlcpy(TheMask, Pattern, sizeof(TheMask) - 3);
-		strlcat(TheMask, "@*", sizeof(TheMask));
-		return TheMask;
-	}
-
-	if (at && !excl) {
+		strlcpy(mask, Pattern, len);
+		strlcat(mask, "@*", len);
+	} else if (at && !excl) {
 		/* User name is missing */
 		*at = '\0'; at++;
-		strlcpy(TheMask, Pattern, sizeof(TheMask) - 5);
-		strlcat(TheMask, "!*@", sizeof(TheMask));
-		strlcat(TheMask, at, sizeof(TheMask));
-		return TheMask;
+		strlcpy(mask, Pattern, len);
+		strlcat(mask, "!*@", len);
+		strlcat(mask, at, len);
+	} else {
+		/* All parts (nick, user and domain name) are given */
+		strlcpy(mask, Pattern, len);
 	}
-
-	/* All parts (nick, user and domain name) are given */
-	strlcpy(TheMask, Pattern, sizeof(TheMask));
-	return TheMask;
 } /* Lists_MakeMask */
 
 /**
blob - eb863db9f0a08c02aa6740a46f2547ae3761ea5e
blob + db0f11a9603691f9eb64f5fcf90b638c007a0876
--- src/ngircd/lists.h
+++ src/ngircd/lists.h
@@ -42,7 +42,7 @@ GLOBAL unsigned long Lists_Count PARAMS((struct list_h
 
 GLOBAL void Lists_Free PARAMS((struct list_head *head));
 
-GLOBAL const char *Lists_MakeMask PARAMS((const char *Pattern));
+GLOBAL void Lists_MakeMask PARAMS((const char *Pattern, char *mask, size_t len));
 GLOBAL const char *Lists_GetMask PARAMS((const struct list_elem *e));
 GLOBAL const char *Lists_GetReason PARAMS((const struct list_elem *e));
 GLOBAL time_t Lists_GetValidity PARAMS((const struct list_elem *e));