voicefont: Detect when the encoded filename overflows the buffer
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Sun, 5 Jul 2026 10:08:05 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 8e89f8a5d66205a18dd1d61ea11c233c6713ffc2 Author: Solomon Peachy <[email protected]> Date: Sun Jul 5 10:06:02 2026 -0400 voicefont: Detect when the encoded filename overflows the buffer ...And handle it gracefully. This shuts up 2 of the 3 remaining rbutil build warnings. Change-Id: I03b057e566ba663a72cbae159e78070b9934fa0d diff --git a/tools/voicefont.c b/tools/voicefont.c index 1d6de63c69..7333121719 100644 --- a/tools/voicefont.c +++ b/tools/voicefont.c @@ -96,8 +96,13 @@ int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output, unsi for (i=0; i<count; i++) { pos[i] = ftell(output); - snprintf(encfilename1, sizeof(encfilename1), "%s%s.enc", filedir, names[i]); - snprintf(encfilename2, sizeof(encfilename2), "%s%s.wav.enc", filedir, names[i]); + if (snprintf(encfilename1, sizeof(encfilename1), "%s%s.enc", filedir, names[i]) >= (int)sizeof(encfilename1) || + snprintf(encfilename2, sizeof(encfilename2), "%s%s.wav.enc", filedir, names[i]) >= (int)sizeof(encfilename2)) { + printf("enc filename '%s' too long!\n", encfilename1); + size[i] = 0; + continue; + } + encfilename = encfilename1; pEncFile = fopen(encfilename, "rb"); if (pEncFile == NULL) -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs