ref: d2be104ba64fa3254587479bcde2ba8bcacfdb8d
parent: 2d0e3fc83ab4dfb51f5552d5f2f2e5313afc764f
author: Paul Brossier <piem@piem.org>
date: Fri Apr 22 16:08:27 EDT 2016
src/io/: also copy null ending char
--- a/src/io/sink_apple_audio.c
+++ b/src/io/sink_apple_audio.c
@@ -67,8 +67,8 @@
goto beach;
}
if (s->path != NULL) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX));
- strncpy(s->path, uri, strnlen(uri, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(uri, PATH_MAX) + 1);
+ strncpy(s->path, uri, strnlen(uri, PATH_MAX) + 1);
s->samplerate = 0;
s->channels = 0;
--- a/src/io/sink_sndfile.c
+++ b/src/io/sink_sndfile.c
@@ -63,8 +63,8 @@
}
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
s->samplerate = 0;
s->channels = 0;
--- a/src/io/sink_wavwrite.c
+++ b/src/io/sink_wavwrite.c
@@ -90,8 +90,8 @@
}
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
s->max_size = MAX_SIZE;
s->bitspersample = 16;
--- a/src/io/source_apple_audio.c
+++ b/src/io/source_apple_audio.c
@@ -96,8 +96,8 @@
UInt32 propSize;
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
// open the resource url
CFURLRef fileURL = createURLFromPath(s->path);
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -86,8 +86,8 @@
s->channels = 1;
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
// register all formats and codecs
av_register_all();
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -88,8 +88,8 @@
s->channels = 1;
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
// try opening the file, getting the info in sfinfo
AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo));
--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -87,8 +87,8 @@
}
if (s->path) AUBIO_FREE(s->path);
- s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX));
- strncpy(s->path, path, strnlen(path, PATH_MAX));
+ s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
+ strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
s->samplerate = samplerate;
s->hop_size = hop_size;