1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 09:50:29 +00:00

Change strdup() to strndup()

This commit is contained in:
Federico G. Schwindt 2013-08-26 12:18:46 +01:00
parent 6ac5a82eec
commit 3b65f4e38d
2 changed files with 5 additions and 4 deletions

View File

@ -469,7 +469,8 @@ Client_SetAccountName(CLIENT *Client, const char *AccountName)
free(Client->account_name);
if (*AccountName)
Client->account_name = strdup(AccountName);
Client->account_name = strndup(AccountName,
CLIENT_NICK_LEN - 1);
else
Client->account_name = NULL;
}

View File

@ -61,7 +61,7 @@ static gnutls_dh_params_t dh_params;
static bool ConnSSL_LoadServerKey_gnutls PARAMS(( void ));
#endif
#define CERTFP_LEN (20 * 2 + 1)
#define SHA1_STRING_LEN (20 * 2 + 1)
static bool ConnSSL_Init_SSL PARAMS(( CONNECTION *c ));
static int ConnectAccept PARAMS(( CONNECTION *c, bool connect ));
@ -723,7 +723,7 @@ ConnSSL_InitCertFp( CONNECTION *c )
assert(c->ssl_state.fingerprint == NULL);
c->ssl_state.fingerprint = malloc(CERTFP_LEN);
c->ssl_state.fingerprint = malloc(SHA1_STRING_LEN);
if (!c->ssl_state.fingerprint)
return 0;
@ -858,7 +858,7 @@ bool
ConnSSL_SetCertFp(CONNECTION *c, const char *fingerprint)
{
assert (c != NULL);
c->ssl_state.fingerprint = strdup(fingerprint);
c->ssl_state.fingerprint = strndup(fingerprint, SHA1_STRING_LEN - 1);
return c->ssl_state.fingerprint != NULL;
}
#else