Sfoglia il codice sorgente

totemknet: Assert strcpy length

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 6 anni fa
parent
commit
29109683cf
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      exec/totemknet.c

+ 9 - 0
exec/totemknet.c

@@ -1022,9 +1022,16 @@ int totemknet_initialize (
 	if (strcmp(instance->totem_config->crypto_cipher_type, "none") != 0) {
 	if (strcmp(instance->totem_config->crypto_cipher_type, "none") != 0) {
 		struct knet_handle_crypto_cfg crypto_cfg;
 		struct knet_handle_crypto_cfg crypto_cfg;
 
 
+		assert(strlen(instance->totem_config->crypto_model) < sizeof(crypto_cfg.crypto_model));
 		strcpy(crypto_cfg.crypto_model, instance->totem_config->crypto_model);
 		strcpy(crypto_cfg.crypto_model, instance->totem_config->crypto_model);
+
+		assert(strlen(instance->totem_config->crypto_cipher_type) < sizeof(crypto_cfg.crypto_cipher_type));
 		strcpy(crypto_cfg.crypto_cipher_type, instance->totem_config->crypto_cipher_type);
 		strcpy(crypto_cfg.crypto_cipher_type, instance->totem_config->crypto_cipher_type);
+
+		assert(strlen(instance->totem_config->crypto_hash_type) < sizeof(crypto_cfg.crypto_hash_type));
 		strcpy(crypto_cfg.crypto_hash_type, instance->totem_config->crypto_hash_type);
 		strcpy(crypto_cfg.crypto_hash_type, instance->totem_config->crypto_hash_type);
+
+		assert(instance->totem_config->private_key_len <= sizeof(crypto_cfg.private_key));
 		memcpy(crypto_cfg.private_key, instance->totem_config->private_key, instance->totem_config->private_key_len);
 		memcpy(crypto_cfg.private_key, instance->totem_config->private_key, instance->totem_config->private_key_len);
 		crypto_cfg.private_key_len = instance->totem_config->private_key_len;
 		crypto_cfg.private_key_len = instance->totem_config->private_key_len;
 
 
@@ -1450,7 +1457,9 @@ int totemknet_reconfigure (
 	int res = 0;
 	int res = 0;
 
 
 	if (totem_config->knet_compression_model) {
 	if (totem_config->knet_compression_model) {
+		assert(strlen(totem_config->knet_compression_model) < sizeof(compress_cfg.compress_model));
 		strcpy(compress_cfg.compress_model, totem_config->knet_compression_model);
 		strcpy(compress_cfg.compress_model, totem_config->knet_compression_model);
+
 		compress_cfg.compress_threshold = totem_config->knet_compression_threshold;
 		compress_cfg.compress_threshold = totem_config->knet_compression_threshold;
 		compress_cfg.compress_level = totem_config->knet_compression_level;
 		compress_cfg.compress_level = totem_config->knet_compression_level;