From 396b867119e15a1def8f6621f69da471a5df3f81 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 21 Dec 2014 12:57:10 +0100 Subject: [PATCH] Reserve one byte extra for the null character. The OSTC3 can display a status message of up to 16 characters large. Since this does not include the terminating null character, the buffer needs to be one byte larger. --- src/hw_ostc3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index a9a683b..a59fceb 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -1054,8 +1054,8 @@ hw_ostc3_device_fwupdate (dc_device_t *abstract, const char *filename) hw_ostc3_device_display (abstract, " Uploading..."); for (unsigned int len = 0; len < SZ_FIRMWARE; len += SZ_FIRMWARE_BLOCK) { - char status[16]; // Status message on the display - snprintf (status, 16, " Uploading %2d%%", (100 * len) / SZ_FIRMWARE); + char status[SZ_DISPLAY + 1]; // Status message on the display + snprintf (status, sizeof(status), " Uploading %2d%%", (100 * len) / SZ_FIRMWARE); hw_ostc3_device_display (abstract, status); rc = hw_ostc3_firmware_block_write (device, FIRMWARE_AREA + len, firmware->data + len, SZ_FIRMWARE_BLOCK); @@ -1073,8 +1073,8 @@ hw_ostc3_device_fwupdate (dc_device_t *abstract, const char *filename) for (unsigned int len = 0; len < SZ_FIRMWARE; len += SZ_FIRMWARE_BLOCK) { unsigned char block[SZ_FIRMWARE_BLOCK]; - char status[16]; // Status message on the display - snprintf (status, 16, " Verifying %2d%%", (100 * len) / SZ_FIRMWARE); + char status[SZ_DISPLAY + 1]; // Status message on the display + snprintf (status, sizeof(status), " Verifying %2d%%", (100 * len) / SZ_FIRMWARE); hw_ostc3_device_display (abstract, status); rc = hw_ostc3_firmware_block_read (device, FIRMWARE_AREA + len, block, sizeof (block));