]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Change strdup() to strndup()
authorFederico G. Schwindt <fgsch@lodoss.net>
Mon, 26 Aug 2013 11:18:46 +0000 (12:18 +0100)
committerFederico G. Schwindt <fgsch@lodoss.net>
Mon, 26 Aug 2013 11:18:46 +0000 (12:18 +0100)
src/ngircd/client.c
src/ngircd/conn-ssl.c

index 1c710344007ab77399d270211432503022bf8614..72774ca9f4c749449d40a9344393aa3f6eef54b0 100644 (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;
 }
index 4156fb192a0b990c644f014c30848ab5d433db75..096ff9512a442ac0091103885b91d738bc05e1c2 100644 (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