summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrett Smith <brett@w3.org>2012-08-23 12:24:34 -0400
committerBrett Smith <brett@w3.org>2012-08-23 12:24:34 -0400
commitc1d7f6216fc26772160f50269d87a74171f8c0a2 (patch)
tree9df161727c9a576f00c006f29a7bd3e869ca57af /src
parent7df4c12da96b2bbc23556c0c334e1d06dd9e4887 (diff)
downloadngircd-c1d7f6216fc26772160f50269d87a74171f8c0a2.tar.gz
ngircd-c1d7f6216fc26772160f50269d87a74171f8c0a2.zip
Implementation clean-ups.
* Have Conn_Password return an empty string when no password has been set,
  to play better with pam.c.

* Use strdup in Conn_SetPassword.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conn.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 03c423e3..20d0cd4f 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -922,19 +922,21 @@ GLOBAL const char*
 Conn_Password( CONN_ID Idx )
 {
   assert( Idx > NONE );
-  return My_Connections[Idx].pwd;
+  if (My_Connections[Idx].pwd == NULL)
+    return (char*)"\0";
+  else
+    return My_Connections[Idx].pwd;
 } /* Conn_Password */
 
 GLOBAL void
 Conn_SetPassword( CONN_ID Idx, const char *Pwd )
 {
   assert( Idx > NONE );
-  My_Connections[Idx].pwd = calloc(strlen(Pwd) + 1, sizeof(char));
+  My_Connections[Idx].pwd = strdup(Pwd);
   if (My_Connections[Idx].pwd == NULL) {
     Log(LOG_EMERG, "Can't allocate memory! [Conn_SetPassword]");
     exit(1);
   }
-  strcpy( My_Connections[Idx].pwd, Pwd );
 } /* Conn_SetPassword */
 
 /**