]> git.proxmox.com Git - mirror_corosync.git/commitdiff
totemconfig: Ensure strncpy is always terminated
authorJan Friesse <jfriesse@redhat.com>
Fri, 9 Apr 2021 10:58:56 +0000 (12:58 +0200)
committerJan Friesse <jfriesse@redhat.com>
Wed, 14 Apr 2021 16:07:50 +0000 (18:07 +0200)
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
exec/totemconfig.c

index 6bd40446422318c0457a2df2cc37655baa2b4e1d..77c7ee03a861138b2e0ebc7185c3f1f4d056a234 100644 (file)
@@ -619,9 +619,14 @@ static int totem_get_crypto(struct totem_config *totem_config, icmap_map_t map,
                totem_config->crypto_changed = 1;
            }
 
-       strncpy(totem_config->crypto_cipher_type, tmp_cipher, CONFIG_STRING_LEN_MAX);
-       strncpy(totem_config->crypto_hash_type, tmp_hash, CONFIG_STRING_LEN_MAX);
-       strncpy(totem_config->crypto_model, tmp_model, CONFIG_STRING_LEN_MAX);
+       strncpy(totem_config->crypto_cipher_type, tmp_cipher, CONFIG_STRING_LEN_MAX - 1);
+       totem_config->crypto_cipher_type[CONFIG_STRING_LEN_MAX - 1] = '\0';
+
+       strncpy(totem_config->crypto_hash_type, tmp_hash, CONFIG_STRING_LEN_MAX - 1);
+       totem_config->crypto_hash_type[CONFIG_STRING_LEN_MAX - 1] = '\0';
+
+       strncpy(totem_config->crypto_model, tmp_model, CONFIG_STRING_LEN_MAX - 1);
+       totem_config->crypto_model[CONFIG_STRING_LEN_MAX - 1] = '\0';
 
 out_free_crypto_model_str:
        free(crypto_model_str);