diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index faadefb2..15e167a1 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -1902,7 +1902,7 @@ fluid_synth_sysex_midi_tuning(fluid_synth_t *synth, const char *data, int len, int bank = 0, prog, channels; double tunedata[128]; int keys[128]; - char name[17]; + char name[17]={0}; int note, frac, frac2; uint8_t chksum; int i, count, index; @@ -1973,7 +1973,8 @@ fluid_synth_sysex_midi_tuning(fluid_synth_t *synth, const char *data, int len, } *resptr++ = prog; - FLUID_STRNCPY(resptr, name, 16); + /* copy 16 ASCII characters (potentially not null terminated) to the sysex buffer */ + FLUID_MEMCPY(resptr, name, 16); resptr += 16; for(i = 0; i < 128; i++) diff --git a/src/utils/fluidsynth_priv.h b/src/utils/fluidsynth_priv.h index 79446925..c7ddf546 100644 --- a/src/utils/fluidsynth_priv.h +++ b/src/utils/fluidsynth_priv.h @@ -261,7 +261,7 @@ typedef FILE *fluid_file; #define FLUID_STRNCPY(_dst,_src,_n) \ do { strncpy(_dst,_src,_n); \ - (_dst)[(_n)-1]=0; \ + (_dst)[(_n)-1]='\0'; \ }while(0) #define FLUID_STRCHR(_s,_c) strchr(_s,_c)