]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Dynamically allocate memory for connection password.
authorBrett Smith <brett@w3.org>
Thu, 23 Aug 2012 16:12:15 +0000 (12:12 -0400)
committerBrett Smith <brett@w3.org>
Thu, 23 Aug 2012 16:12:15 +0000 (12:12 -0400)
src/ngircd/conn.c
src/ngircd/conn.h

index 4900d7b803361737de363240867cfec6e001c0df..03c423e35e0d5616e7204e4488ebfe1cf6953bdd 100644 (file)
@@ -929,8 +929,12 @@ GLOBAL void
 Conn_SetPassword( CONN_ID Idx, const char *Pwd )
 {
   assert( Idx > NONE );
-  strlcpy( My_Connections[Idx].pwd, Pwd,
-          sizeof(My_Connections[Idx].pwd) );
+  My_Connections[Idx].pwd = calloc(strlen(Pwd) + 1, sizeof(char));
+  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 */
 
 /**
@@ -1160,6 +1164,8 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie
 
        array_free(&My_Connections[Idx].rbuf);
        array_free(&My_Connections[Idx].wbuf);
+       if (My_Connections[Idx].pwd != NULL)
+         free(My_Connections[Idx].pwd);
 
        /* Clean up connection structure (=free it) */
        Init_Conn_Struct( Idx );
index 9ee979f2da4502ed28e00222b610c201880f6d43..341489aaffe7db4a6330754358f997c9b9bf2c72 100644 (file)
@@ -72,7 +72,7 @@ typedef struct _Connection
        ng_ipaddr_t addr;               /* Client address */
        PROC_STAT proc_stat;            /* Status of resolver process */
        char host[HOST_LEN];            /* Hostname */
-       char pwd[CLIENT_PASS_LEN];      /* password received of the client */
+       char *pwd;                      /* password received of the client */
        array rbuf;                     /* Read buffer */
        array wbuf;                     /* Write buffer */
        time_t signon;                  /* Signon ("connect") time */