diff options
author | Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com> | 2022-03-30 20:55:33 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com> | 2022-03-30 20:55:33 +0000 |
commit | 5ddff681670a0090cab6486d467399d92dffbef6 (patch) | |
tree | 55d3f2e3a1d55beed0c81c6f2c6efe433de864d7 | |
parent | cb4d441cb81100c883c4dfede5a92eaa5a9fc13e (diff) |
libtags: m4a: do not div by zero
-rw-r--r-- | sys/src/cmd/audio/libtags/m4a.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/src/cmd/audio/libtags/m4a.c b/sys/src/cmd/audio/libtags/m4a.c index b1e0fda30..924ba51a2 100644 --- a/sys/src/cmd/audio/libtags/m4a.c +++ b/sys/src/cmd/audio/libtags/m4a.c @@ -8,6 +8,7 @@ int tagm4a(Tagctx *ctx) { uvlong duration; + uint x; uchar *d; int sz, type, dtype, i, skip, n; @@ -101,12 +102,14 @@ tagm4a(Tagctx *ctx) if(ctx->read(ctx, d, 16) != 16) return -1; sz -= 16; - duration = beuint(&d[12]) / beuint(&d[8]); + if((x = beuint(&d[8])) > 0) + duration = beuint(&d[12]) / x; }else if(d[1] == 1){ /* version 1 */ if(ctx->read(ctx, d, 28) != 28) return -1; sz -= 28; - duration = ((uvlong)beuint(&d[20])<<32 | beuint(&d[24])) / (uvlong)beuint(&d[16]); + if((x = beuint(&d[16])) > 0) + duration = ((uvlong)beuint(&d[20])<<32 | beuint(&d[24])) / (uvlong)x; } ctx->duration = duration * 1000; continue; |