Browse Source

Add trailing zero in version field

master
Olaf Rempel 3 months ago
parent
commit
fcbcbcb9af
2 changed files with 8 additions and 4 deletions
  1. +4
    -2
      mpm.c
  2. +4
    -2
      twi.c

+ 4
- 2
mpm.c View File

@@ -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)))
{


+ 4
- 2
twi.c View File

@@ -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))
{


Loading…
Cancel
Save