mirror of
https://github.com/osmarks/ngircd.git
synced 2024-10-28 12:56:18 +00:00
Dynamically allocate memory for connection password.
This commit is contained in:
parent
0d5de60584
commit
7df4c12da9
@ -929,8 +929,12 @@ GLOBAL void
|
|||||||
Conn_SetPassword( CONN_ID Idx, const char *Pwd )
|
Conn_SetPassword( CONN_ID Idx, const char *Pwd )
|
||||||
{
|
{
|
||||||
assert( Idx > NONE );
|
assert( Idx > NONE );
|
||||||
strlcpy( My_Connections[Idx].pwd, Pwd,
|
My_Connections[Idx].pwd = calloc(strlen(Pwd) + 1, sizeof(char));
|
||||||
sizeof(My_Connections[Idx].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 */
|
} /* 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].rbuf);
|
||||||
array_free(&My_Connections[Idx].wbuf);
|
array_free(&My_Connections[Idx].wbuf);
|
||||||
|
if (My_Connections[Idx].pwd != NULL)
|
||||||
|
free(My_Connections[Idx].pwd);
|
||||||
|
|
||||||
/* Clean up connection structure (=free it) */
|
/* Clean up connection structure (=free it) */
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
@ -72,7 +72,7 @@ typedef struct _Connection
|
|||||||
ng_ipaddr_t addr; /* Client address */
|
ng_ipaddr_t addr; /* Client address */
|
||||||
PROC_STAT proc_stat; /* Status of resolver process */
|
PROC_STAT proc_stat; /* Status of resolver process */
|
||||||
char host[HOST_LEN]; /* Hostname */
|
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 rbuf; /* Read buffer */
|
||||||
array wbuf; /* Write buffer */
|
array wbuf; /* Write buffer */
|
||||||
time_t signon; /* Signon ("connect") time */
|
time_t signon; /* Signon ("connect") time */
|
||||||
|
Loading…
Reference in New Issue
Block a user