]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Implementation clean-ups.
authorBrett Smith <brett@w3.org>
Thu, 23 Aug 2012 16:24:34 +0000 (12:24 -0400)
committerBrett Smith <brett@w3.org>
Thu, 23 Aug 2012 16:24:34 +0000 (12:24 -0400)
* Have Conn_Password return an empty string when no password has been set,
  to play better with pam.c.

* Use strdup in Conn_SetPassword.

src/ngircd/conn.c

index 03c423e35e0d5616e7204e4488ebfe1cf6953bdd..20d0cd4ffc6afd51ab5712c8c182e6363495b5b0 100644 (file)
@@ -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 */
 
 /**