From cb4d441cb81100c883c4dfede5a92eaa5a9fc13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Wed, 30 Mar 2022 20:54:11 +0000 Subject: [PATCH] libtags: wav: do not div by zero (fixup) --- sys/src/cmd/audio/libtags/wav.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/src/cmd/audio/libtags/wav.c b/sys/src/cmd/audio/libtags/wav.c index 4b284faeb..1e36b0e33 100644 --- a/sys/src/cmd/audio/libtags/wav.c +++ b/sys/src/cmd/audio/libtags/wav.c @@ -19,7 +19,7 @@ tagwav(Tagctx *ctx) { uchar *d; int i, n, info; - u32int csz; + u32int csz, x; uvlong sz; d = (uchar*)ctx->buf; @@ -59,9 +59,10 @@ tagwav(Tagctx *ctx) csz -= 16; ctx->channels = le16u(d+2); ctx->samplerate = leuint(d+4); - if(ctx->channels < 1 || ctx->samplerate < 1) + x = leuint(d+8); + if(ctx->channels < 1 || ctx->samplerate < 1 || x < 1) return -1; - ctx->duration = sz*1000 / leuint(d+8); + ctx->duration = sz*1000 / x; }else if(memcmp(d, "LIST", 4) == 0){ sz = csz - 4; continue;