1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
From: ihy123 <aladinandreyy@gmail.com>
Date: Sun, 17 Aug 2025 14:28:46 +0300
Subject: Validate sample format in ip_open()
To prevent segfault in ip_setup() because channels=0, validate ip_data->sf
after opening ip.
---
input.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/input.c b/input.c
index c20cb3f..f5c5b3c 100644
--- a/input.c
+++ b/input.c
@@ -605,6 +605,16 @@ int ip_open(struct input_plugin *ip)
ip_reset(ip, 1);
return rc;
}
+
+ unsigned bits = sf_get_bits(ip->data.sf);
+ unsigned channels = sf_get_channels(ip->data.sf);
+ unsigned rate = sf_get_rate(ip->data.sf);
+ if (!bits || !channels || !rate) {
+ d_print("corrupt file: bits = %u, channels = %u, rate = %u\n",
+ bits, channels, rate);
+ return -IP_ERROR_FILE_FORMAT;
+ }
+
ip->open = 1;
return 0;
}
|