shithub: riscv

Download patch

ref: cb4d441cb81100c883c4dfede5a92eaa5a9fc13e
parent: 2cdd31f8f4b6b4b24d13428378e225caa7aa8c70
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 30 16:54:11 EDT 2022

libtags: wav: do not div by zero (fixup)

--- a/sys/src/cmd/audio/libtags/wav.c
+++ b/sys/src/cmd/audio/libtags/wav.c
@@ -19,7 +19,7 @@
 {
 	uchar *d;
 	int i, n, info;
-	u32int csz;
+	u32int csz, x;
 	uvlong sz;
 
 	d = (uchar*)ctx->buf;
@@ -59,9 +59,10 @@
 			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;