check for signature

This commit is contained in:
Nishi 2025-11-27 04:50:14 +09:00
commit 2de15ac054
Signed by: nishi
GPG key ID: 27EF69B208EB9343

View file

@ -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");