diff options
| author | Brett Smith <brett@w3.org> | 2012-08-23 12:12:15 -0400 |
|---|---|---|
| committer | Brett Smith <brett@w3.org> | 2012-08-23 12:12:15 -0400 |
| commit | 7df4c12da96b2bbc23556c0c334e1d06dd9e4887 (patch) | |
| tree | eb4e3cadeadea5b07e3177952f23930dc66039ea /src | |
| parent | 0d5de60584f094ef3b7c27806d6cd7f79e861d7b (diff) | |
| download | ngircd-7df4c12da96b2bbc23556c0c334e1d06dd9e4887.tar.gz ngircd-7df4c12da96b2bbc23556c0c334e1d06dd9e4887.zip | |
Dynamically allocate memory for connection password.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/conn.c | 10 | ||||
| -rw-r--r-- | src/ngircd/conn.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 4900d7b8..03c423e3 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -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 ); diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index 9ee979f2..341489aa 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -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 */ |