const char *dmi_memory_device_form_factor(uint8_t code);
void dmi_memory_device_set(uint8_t code, char *set);
const char *dmi_memory_device_type(uint8_t code);
-void dmi_memory_device_type_detail(uint16_t code, char *type_detail);
+void dmi_memory_device_type_detail(uint16_t code, char *type_detail, int sizeof_type_detail);
void dmi_memory_device_speed(uint16_t code, char *speed);
-void dmi_memory_module_connections(uint8_t, char *);
+void dmi_memory_module_connections(uint8_t, char *, int);
void dmi_memory_module_speed(uint8_t, char *);
-void dmi_memory_module_types(uint16_t, const char *, char *);
-void dmi_memory_module_size(uint8_t, char *);
+void dmi_memory_module_types(uint16_t, const char *, char *, int);
+void dmi_memory_module_size(uint8_t, char *, int);
void dmi_memory_module_error(uint8_t, const char *, char *);
#endif
int found = 0;
/* Cleaning structures */
+ memset(dmi, 0, sizeof(s_dmi));
+
memset(&dmi->base_board, 0, sizeof(s_base_board));
memset(&dmi->battery, 0, sizeof(s_battery));
memset(&dmi->bios, 0, sizeof(s_bios));
dmi->memory_module[dmi->memory_module_count - 1].filled = true;
strlcpy(module->socket_designation, dmi_string(h, data[0x04]),
sizeof(module->socket_designation));
- dmi_memory_module_connections(data[0x05], module->bank_connections);
+ dmi_memory_module_connections(data[0x05], module->bank_connections, sizeof(module->bank_connections));
dmi_memory_module_speed(data[0x06], module->speed);
- dmi_memory_module_types(WORD(data + 0x07), " ", module->type);
- dmi_memory_module_size(data[0x09], module->installed_size);
- dmi_memory_module_size(data[0x0A], module->enabled_size);
+ dmi_memory_module_types(WORD(data + 0x07), " ", module->type, sizeof(module->type));
+ dmi_memory_module_size(data[0x09], module->installed_size, sizeof(module->installed_size));
+ dmi_memory_module_size(data[0x0A], module->enabled_size, sizeof(module->enabled_size));
dmi_memory_module_error(data[0x0B], "\t\t", module->error_status);
break;
case 7: /* 3.3.8 Cache Information */
sizeof(mem->bank_locator));
strlcpy(mem->type, dmi_memory_device_type(data[0x12]),
sizeof(mem->type));
- dmi_memory_device_type_detail(WORD(data + 0x13), mem->type_detail);
+ dmi_memory_device_type_detail(WORD(data + 0x13), mem->type_detail, sizeof(mem->type_detail));
if (h->length < 0x17)
break;
dmi_memory_device_speed(WORD(data + 0x15), mem->speed);
return out_of_spec;
}
-void dmi_memory_device_type_detail(uint16_t code, char *type_detail)
+void dmi_memory_device_type_detail(uint16_t code, char *type_detail, int sizeof_type_detail)
{
/* 3.3.18.3 */
static const char *detail[] = {
for (i = 1; i <= 12; i++)
if (code & (1 << i))
- snprintf(type_detail,sizeof(type_detail), "%s", detail[i - 1]);
+ snprintf(type_detail, sizeof_type_detail, "%s", detail[i - 1]);
}
}
* 3.3.7 Memory Module Information (Type 6)
*/
-void dmi_memory_module_types(uint16_t code, const char *sep, char *type)
+void dmi_memory_module_types(uint16_t code, const char *sep, char *type, int sizeof_type)
{
/* 3.3.7.1 */
static const char *types[] = {
for (i = 0; i <= 10; i++)
if (code & (1 << i))
- snprintf(type,sizeof(type), "%s%s%s", type, sep, types[i]);
+ snprintf(type, sizeof_type, "%s%s%s", type, sep, types[i]);
}
}
-void dmi_memory_module_connections(uint8_t code, char *connection)
+void dmi_memory_module_connections(uint8_t code, char *connection, int sizeof_connection)
{
if (code == 0xFF)
sprintf(connection, "%s", "None");
if ((code & 0xF0) != 0xF0)
sprintf(connection, "%u ", code >> 4);
if ((code & 0x0F) != 0x0F)
- snprintf(connection,sizeof(connection), "%s%u", connection, code & 0x0F);
+ snprintf(connection, sizeof_connection, "%s%u", connection, code & 0x0F);
}
}
sprintf(speed, "%u ns", code);
}
-void dmi_memory_module_size(uint8_t code, char *size)
+void dmi_memory_module_size(uint8_t code, char *size, int sizeof_size)
{
/* 3.3.7.2 */
switch (code & 0x7F) {
}
if (code & 0x80)
- snprintf(size,sizeof(size),"%s %s", size, "(Double-bank Connection)");
+ snprintf(size, sizeof_size, "%s %s", size, "(Double-bank Connection)");
else
- snprintf(size,sizeof(size), "%s %s", size, "(Single-bank Connection)");
+ snprintf(size, sizeof_size, "%s %s", size, "(Single-bank Connection)");
}
void dmi_memory_module_error(uint8_t code, const char *prefix, char *error)