فهرست منبع

totemcrypto: Check length of the packet

Packet has to be longer than crypto_config_header and hash_len,
otherwise unallocated memory is passed into calculate_nss_hash function,
what may result in crash.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Raphael Sanchez Prudencio <rasanche@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 8 سال پیش
والد
کامیت
fc1d541853
1فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 11 0
      exec/totemcrypto.c

+ 11 - 0
exec/totemcrypto.c

@@ -736,6 +736,11 @@ static int authenticate_nss_2_3 (
 		unsigned char	tmp_hash[hash_len[instance->crypto_hash_type]];
 		int             datalen = *buf_len - hash_len[instance->crypto_hash_type];
 
+		if (*buf_len <= hash_len[instance->crypto_hash_type]) {
+			log_printf(instance->log_level_security, "Received message is too short...  ignoring");
+			return -1;
+		}
+
 		if (calculate_nss_hash(instance, buf, datalen, tmp_hash) < 0) {
 			return -1;
 		}
@@ -846,6 +851,12 @@ int crypto_authenticate_and_decrypt (struct crypto_instance *instance,
 	struct crypto_config_header *cch = (struct crypto_config_header *)buf;
 	const char *guessed_str;
 
+	if (*buf_len <= sizeof(struct crypto_config_header)) {
+		log_printf(instance->log_level_security, "Received message is too short...  ignoring");
+
+		return (-1);
+	}
+
 	if (cch->crypto_cipher_type != CRYPTO_CIPHER_TYPE_2_3) {
 		guessed_str = NULL;