shithub: aubio

Download patch

ref: b1559f4c9ce2b304d8d27ffdc7128b6795ca82e5
parent: c4a8bc138e49de8b43fcd2221ef84dfa5073208f
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 12:17:29 EST 2018

[tempo] fix buffer overflow in method parser

--- a/src/tempo/tempo.c
+++ b/src/tempo/tempo.c
@@ -168,7 +168,7 @@
     uint_t buf_size, uint_t hop_size, uint_t samplerate)
 {
   aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t);
-  char_t specdesc_func[20];
+  char_t specdesc_func[PATH_MAX];
   o->samplerate = samplerate;
   // check parameters are valid
   if ((sint_t)hop_size < 1) {
@@ -203,9 +203,10 @@
   o->pp       = new_aubio_peakpicker();
   aubio_peakpicker_set_threshold (o->pp, o->threshold);
   if ( strcmp(tempo_mode, "default") == 0 ) {
-    strcpy(specdesc_func, "specflux");
+    strncpy(specdesc_func, "specflux", PATH_MAX - 1);
   } else {
-    strcpy(specdesc_func, tempo_mode);
+    strncpy(specdesc_func, tempo_mode, PATH_MAX - 1);
+    specdesc_func[PATH_MAX - 1] = '\0';
   }
   o->od       = new_aubio_specdesc(specdesc_func,buf_size);
   o->of       = new_fvec(1);