ref: 7fcd37916f92e56bd945af0496287b5db8cc8756
parent: 94672541fd9dc77636fb5fdb04b6ea87eedb6b8d
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 30 14:57:43 EDT 2022
flac: check sample rate before dividing by zero; also check number of channels
--- a/flac.c
+++ b/flac.c
@@ -1,7 +1,7 @@
/* https://xiph.org/flac/format.html */
#include "tagspriv.h"
-#define beu3(d) ((d)[0]<<16 | (d)[1]<<8 | (d)[2]<<0)
+#define beu3(d) ((d)[0]<<16 | (d)[1]<<8 | (d)[2]<<0)
int
tagflac(Tagctx *ctx)
@@ -18,6 +18,9 @@
sz = beu3(&d[5]); /* size of the stream info */
ctx->samplerate = beu3(&d[18]) >> 4;
ctx->channels = ((d[20]>>1) & 7) + 1;
+ if(ctx->samplerate < 1 || ctx->channels < 1)
+ return -1;
+
g = (uvlong)(d[21] & 0xf)<<32 | beu3(&d[22])<<8 | d[25];
ctx->duration = g * 1000 / ctx->samplerate;