Переглянути джерело

snmpstats: fixed faulty allocation of snmp stats array

- the size of struct was used while the pointer to that struct was in
  the array
- reported by Paul Pankhurst
Daniel-Constantin Mierla 14 роки тому
батько
коміт
52ce234923
1 змінених файлів з 4 додано та 4 видалено
  1. 4 4
      modules_k/snmpstats/snmpstats.c

+ 4 - 4
modules_k/snmpstats/snmpstats.c

@@ -195,10 +195,10 @@ static int register_message_code_statistics(void)
 		sizeof(in_message_code_names) / sizeof(char *);
 		sizeof(in_message_code_names) / sizeof(char *);
 
 
 	in_message_code_stats = 
 	in_message_code_stats = 
-		shm_malloc(sizeof(stat_var) * number_of_message_codes);
+		shm_malloc(sizeof(stat_var*) * number_of_message_codes);
 
 
 	out_message_code_stats = 
 	out_message_code_stats = 
-		shm_malloc(sizeof(stat_var) * number_of_message_codes);
+		shm_malloc(sizeof(stat_var*) * number_of_message_codes);
 
 
 	/* We can only proceed if we had enough memory to allocate the
 	/* We can only proceed if we had enough memory to allocate the
 	 * statistics.  Note that we don't free the memory, but we don't care
 	 * statistics.  Note that we don't free the memory, but we don't care
@@ -210,8 +210,8 @@ static int register_message_code_statistics(void)
 	}
 	}
 
 
 	/* Make sure everything is zeroed out */
 	/* Make sure everything is zeroed out */
-	memset(in_message_code_stats,  0, number_of_message_codes);
-	memset(out_message_code_stats, 0, number_of_message_codes);
+	memset(in_message_code_stats,  0, sizeof(stat_var*) * number_of_message_codes);
+	memset(out_message_code_stats, 0, sizeof(stat_var*) * number_of_message_codes);
 
 
 	for (i = 0; i < number_of_message_codes; i++) 
 	for (i = 0; i < number_of_message_codes; i++) 
 	{
 	{