dfffile: handle invalid channels and rate

Missing or malformed headers could cause unspecified channels or rate
that can cause crashes.
This commit is contained in:
Wim Taymans 2026-05-08 17:12:54 +02:00
parent 57770c7e18
commit b5d294eab0

View file

@ -186,6 +186,8 @@ static int read_FRM8(struct dff_file *f)
break;
case FOURCC('D', 'S', 'D', ' '):
{
if (f->info.channels == 0)
return -EINVAL;
f->info.length = c[1].size;
f->info.samples = c[1].size / f->info.channels;
f->info.lsb = 0;
@ -221,6 +223,11 @@ static int open_read(struct dff_file *f, const char *filename, struct dff_file_i
if ((res = read_FRM8(f)) < 0)
goto exit_close;
if (f->info.channels == 0 || f->info.rate == 0) {
res = -EINVAL;
goto exit_close;
}
f->blocksize = BLOCKSIZE * f->info.channels;
f->buffer = calloc(1, f->blocksize);
if (f->buffer == NULL) {