ref: dc724763680110a1df03f7f53cda1d7aa390df79
parent: 252f58538ca8cab5e69b389a9e9d1f81cff272d9
author: Paul Brossier <piem@piem.org>
date: Mon Dec 17 10:11:17 EST 2018
[io] sink_vorbis: check input sizes
--- a/src/io/sink_vorbis.c
+++ b/src/io/sink_vorbis.c
@@ -36,6 +36,8 @@
#include <errno.h> // errno
#include <time.h> // time
+#define MAX_SIZE 2048
+
struct _aubio_sink_vorbis_t {
FILE *fid; // file id
ogg_stream_state os; // stream
@@ -244,7 +246,9 @@
uint_t write)
{
uint_t c, v;
- float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
+ uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
+ MAX_SIZE, write_data->length, write);
+ float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
// fill buffer
if (!write) {
return;
@@ -253,12 +257,12 @@
return;
} else {
for (c = 0; c < s->channels; c++) {
- for (v = 0; v < write; v++) {
+ for (v = 0; v < length; v++) {
buffer[c][v] = write_data->data[v];
}
}
// tell vorbis how many frames were written
- vorbis_analysis_wrote(&s->vd, (long)write);
+ vorbis_analysis_wrote(&s->vd, (long)length);
}
// write to file
aubio_sink_vorbis_write(s);
@@ -268,8 +272,11 @@
uint_t write)
{
uint_t c, v;
- uint_t channels = MIN(s->channels, write_data->height);
- float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
+ uint_t channels = aubio_sink_validate_input_channels("sink_vorbis", s->path,
+ s->channels, write_data->height);
+ uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
+ MAX_SIZE, write_data->length, write);
+ float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
// fill buffer
if (!write) {
return;
@@ -278,7 +285,7 @@
return;
} else {
for (c = 0; c < channels; c++) {
- for (v = 0; v < write; v++) {
+ for (v = 0; v < length; v++) {
buffer[c][v] = write_data->data[c][v];
}
}