Changeset dc72476 for src/io


Ignore:
Timestamp:
Dec 17, 2018, 3:11:17 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
Children:
7e2eef4
Parents:
252f585
Message:

[io] sink_vorbis: check input sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_vorbis.c

    r252f585 rdc72476  
    3636#include <errno.h> // errno
    3737#include <time.h> // time
     38
     39#define MAX_SIZE 2048
    3840
    3941struct _aubio_sink_vorbis_t {
     
    245247{
    246248  uint_t c, v;
    247   float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
     249  uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
     250      MAX_SIZE, write_data->length, write);
     251  float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
    248252  // fill buffer
    249253  if (!write) {
     
    254258  } else {
    255259    for (c = 0; c < s->channels; c++) {
    256       for (v = 0; v < write; v++) {
     260      for (v = 0; v < length; v++) {
    257261        buffer[c][v] = write_data->data[v];
    258262      }
    259263    }
    260264    // tell vorbis how many frames were written
    261     vorbis_analysis_wrote(&s->vd, (long)write);
     265    vorbis_analysis_wrote(&s->vd, (long)length);
    262266  }
    263267  // write to file
     
    269273{
    270274  uint_t c, v;
    271   uint_t channels = MIN(s->channels, write_data->height);
    272   float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
     275  uint_t channels = aubio_sink_validate_input_channels("sink_vorbis", s->path,
     276      s->channels, write_data->height);
     277  uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
     278      MAX_SIZE, write_data->length, write);
     279  float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
    273280  // fill buffer
    274281  if (!write) {
     
    279286  } else {
    280287    for (c = 0; c < channels; c++) {
    281       for (v = 0; v < write; v++) {
     288      for (v = 0; v < length; v++) {
    282289        buffer[c][v] = write_data->data[c][v];
    283290      }
Note: See TracChangeset for help on using the changeset viewer.