ref: 7b6a889217d62ed7e28188621403cc7542fd1f7e
parent: 2f6b3fec2dddfbb869a9f7de3110c9aaa31517c9
author: Mans Rullgard <mans@mansr.com>
date: Tue Feb 4 07:55:18 EST 2020
sox-fmt: validate comments_bytes before use (CVE-2019-13590) [bug #325] Cap the comments size to 1 GB to avoid overflows in subsequent arithmetic. The missing null check mentioned in the bug report is bogus since lsx_calloc() returns a valid pointer or aborts.
--- a/src/sox-fmt.c
+++ b/src/sox-fmt.c
@@ -46,7 +46,9 @@
lsx_readdw(ft, &comments_bytes))
return SOX_EOF;
- if (((headers_bytes + 4) & 7) || headers_bytes < FIXED_HDR + comments_bytes ||
+ if (((headers_bytes + 4) & 7) ||
+ comments_bytes > 0x40000000 || /* max 1 GB */
+ headers_bytes < FIXED_HDR + comments_bytes ||
(num_channels > 65535)) /* Reserve top 16 bits */ {
lsx_fail_errno(ft, SOX_EHDR, "invalid sox file format header");
return SOX_EOF;