From efbffe16b44f1aba9574c417eed2ef061ab83192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Andr=C3=A9n=20Zachrisson?= Date: Sun, 1 Nov 2015 13:48:27 +0100 Subject: [PATCH] Revert back to static 4 byte copy and add an assert protecting the runtime --- cue2pops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cue2pops.c b/cue2pops.c index f66c99f..bf34aa4 100644 --- a/cue2pops.c +++ b/cue2pops.c @@ -1030,8 +1030,13 @@ int main(int argc, char **argv) printf("daTrack_ptr LBA = %d (%Xh)\n\n", daTrack_ptr / SECTORSIZE, daTrack_ptr / SECTORSIZE); } - memcpy(headerbuf + 1032, §or_count, sizeof(sector_count)); // Sector Count (LEHEX) - memcpy(headerbuf + 1036, §or_count, sizeof(sector_count)); // Sector Count (LEHEX) + if (sizeof(sector_count) != 4) { + printf("Error: sector_count variable is not 4 bytes. This will break the header generation.\n"); + return 0; + } + + memcpy(headerbuf + 1032, §or_count, 4); // Sector Count (LEHEX) + memcpy(headerbuf + 1036, §or_count, 4); // Sector Count (LEHEX) headerbuf[1024] = 0x6B; headerbuf[1025] = 0x48;