diff --git a/mpm.c b/mpm.c index 6408134..fbe7a73 100644 --- a/mpm.c +++ b/mpm.c @@ -682,14 +682,16 @@ static int mpm_open(struct multiboot *mboot) /* wait for watchdog and startup time */ usleep(100000); - char version[16]; - if (mpm_read_version(mpm, (uint8_t *)version, sizeof(version))) + char version[16 +1]; + if (mpm_read_version(mpm, (uint8_t *)version, sizeof(version) -1)) { fprintf(stderr, "failed to get bootloader version\n"); mpm_close(mboot); return -1; } + version[16] = '\0'; + uint8_t chipinfo[8]; if (mpm_read_chipinfo(mpm, chipinfo, sizeof(chipinfo))) { diff --git a/twi.c b/twi.c index 48f0755..2abd070 100644 --- a/twi.c +++ b/twi.c @@ -310,8 +310,8 @@ static int twi_open(struct multiboot *mboot) /* wait for watchdog and startup time */ usleep(100000); - char version[16]; - if (twi_read_version(twi, version, sizeof(version))) + char version[16 +1]; + if (twi_read_version(twi, version, sizeof(version) -1)) { fprintf(stderr, "failed to get bootloader version: %s\n", strerror(errno)); @@ -320,6 +320,8 @@ static int twi_open(struct multiboot *mboot) return -1; } + version[16] = '\0'; + uint8_t chipinfo[8]; if (twi_read_memory(twi, chipinfo, sizeof(chipinfo), MEMTYPE_CHIPINFO, 0x0000)) {