From 2de15ac054c90bdf9ab5e81777371012f89a1108 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 27 Nov 2025 04:50:14 +0900 Subject: [PATCH] check for signature --- sound/drv_mp3.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/drv_mp3.c b/sound/drv_mp3.c index e06f85b..4370d8c 100644 --- a/sound/drv_mp3.c +++ b/sound/drv_mp3.c @@ -7,6 +7,16 @@ static MDESoundContext mp3_open(const char* path) { MDESoundContext ctx = malloc(sizeof(*ctx)); char* s; + unsigned char sig[3]; + FILE* f = fopen(path, "rb"); + fread(sig, 3, 1, f); + if(memcmp(sig, "ID3", 3) != 0 && memcmp(sig, "\xff\xfb", 2) != 0 && memcmp(sig, "\xff\xf3", 2) != 0 && memcmp(sig, "\xff\xf2", 2) != 0) { + free(ctx); + fclose(f); + return NULL; + } + + fclose(f); memset(ctx, 0, sizeof(*ctx)); ctx->title = MDEID3GetString(path, "TIT2");