From d1ffaa8949998099abcc8611e5f66a0c496c66ee Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Wed, 6 Nov 2024 09:33:40 -0500 Subject: [PATCH] convbdf: Properly support a compiled sysfont of over 64K. The 'struct font' definition says: const void *offset; /* offsets into bitmap data, uint16_t if bits_size < 0xFFDB else uint32_t*/ However convbdf was unconditionally using 'unsigned short' without checking bits_size. This generated a bogus table if used with an uncapped SYSFONT due to offeset overflows. And a pile of complier warnings. That said, we're still capping SYSFONT at 255 chars due to space constraints -- 14-Rockbox-mix jumps from 2.6K to 1022K if left uncapped. Yowza. Change-Id: I4577da08ab1633ab7abbc167523196f38c8a348a --- tools/convbdf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/convbdf.c b/tools/convbdf.c index 58ab2645b4..4602b9e633 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c @@ -1347,7 +1347,7 @@ int gen_c_source(struct font* pf, char *path) if (pf->offset) { /* output offset table */ fprintf(ofp, "/* Character->glyph mapping. */\n" - "static const unsigned short _sysfont_offset[] = {\n"); + "static const unsigned %s _sysfont_offset[] = {\n", pf->bits_size > 0xffdb ? "long" : "short"); for (i=0; isize; ++i) { int offset = pf->offset[i];