superio: Always ensure the version string is NUL terminated

Spotted by Coverity
This commit is contained in:
Richard Hughes 2021-07-10 10:05:09 +01:00
parent f1dbd42934
commit df297d3ee2

View File

@ -92,12 +92,12 @@ fu_superio_it55_device_ec_project (FuSuperioDevice *device, GError **error)
static gboolean static gboolean
fu_superio_it55_device_ec_version (FuSuperioDevice *self, GError **error) fu_superio_it55_device_ec_version (FuSuperioDevice *self, GError **error)
{ {
gchar version[16] = "1."; gchar version[16] = { '1', '.', '\0' };
if (!fu_superio_device_ec_write_cmd (self, SIO_CMD_EC_GET_VERSION_STR, error)) if (!fu_superio_device_ec_write_cmd (self, SIO_CMD_EC_GET_VERSION_STR, error))
return FALSE; return FALSE;
for (guint i = 2; i < sizeof(version) - 1; ++i) { for (guint i = 2; i < sizeof(version) - 1; i++) {
guint8 tmp = 0; guint8 tmp = 0;
if (!fu_superio_device_ec_read_data (self, &tmp, error)) { if (!fu_superio_device_ec_read_data (self, &tmp, error)) {
g_prefix_error (error, "failed to read firmware version: "); g_prefix_error (error, "failed to read firmware version: ");