about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@lodoss.net>2013-08-26 22:52:23 +0100
committerFederico G. Schwindt <fgsch@lodoss.net>2013-08-27 00:06:03 +0100
commitbe2e611680834cf469c31ff0a230f1bf6d55c554 (patch)
treeea1beb8a629a736f3e9f7b2f736624aa23d7593a /src
parent41f75b69740bd205864bd34afbb65ab0a3776136 (diff)
downloadngircd-be2e611680834cf469c31ff0a230f1bf6d55c554.tar.gz
ngircd-be2e611680834cf469c31ff0a230f1bf6d55c554.zip
Change away to be allocated dynamically
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/client.c10
-rw-r--r--src/ngircd/client.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 2835b46f..37b97d68 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -221,7 +221,7 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
 		Generate_MyToken(client);
 
 	if (Client_HasMode(client, 'a'))
-		strlcpy(client->away, DEFAULT_AWAY_MSG, sizeof(client->away));
+		client->away = strndup(DEFAULT_AWAY_MSG, CLIENT_AWAY_LEN - 1);
 
 	client->next = (POINTER *)My_Clients;
 	My_Clients = client;
@@ -500,7 +500,11 @@ Client_SetAway( CLIENT *Client, const char *Txt )
 	assert( Client != NULL );
 	assert( Txt != NULL );
 
-	strlcpy( Client->away, Txt, sizeof( Client->away ));
+	if (Client->away)
+		free(Client->away);
+
+	Client->away = strndup(Txt, CLIENT_AWAY_LEN - 1);
+
 	LogDebug("%s \"%s\" is away: %s", Client_TypeText(Client),
 		 Client_Mask(Client), Txt);
 } /* Client_SetAway */
@@ -1441,6 +1445,8 @@ Free_Client(CLIENT **Client)
 
 	if ((*Client)->account_name)
 		free((*Client)->account_name);
+	if ((*Client)->away)
+		free((*Client)->away);
 	if ((*Client)->cloaked)
 		free((*Client)->cloaked);
 	if ((*Client)->ipa_text)
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
index 71d413b2..c104a75b 100644
--- a/src/ngircd/client.h
+++ b/src/ngircd/client.h
@@ -58,7 +58,7 @@ typedef struct _CLIENT
 	char modes[CLIENT_MODE_LEN];	/* client modes */
 	int hops, token, mytoken;	/* "hops" and "Token" (see SERVER command) */
 	bool oper_by_me;		/* client is local IRC operator on this server? */
-	char away[CLIENT_AWAY_LEN];	/* AWAY text (valid if mode 'a' is set) */
+	char *away;			/* AWAY text (valid if mode 'a' is set) */
 	char flags[CLIENT_FLAGS_LEN];	/* flags of the client */
 	char *account_name;		/* login account (for services) */
 	int capabilities;		/* enabled IRC capabilities */