Skip to content

Commit

Permalink
audio/zynaddsubfx: Fix buffer overflows
Browse files Browse the repository at this point in the history
- Leave room for termination NUL in sscanf buffer.
- Use float instead of float_t.  On FreeBSD/i386 they are not the same.

Discovered during an exp-run for bug 276478.
  • Loading branch information
TijlCoosemans committed Feb 29, 2024
1 parent 9827f3b commit 0eb74ba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion audio/zynaddsubfx/Makefile
@@ -1,6 +1,6 @@
PORTNAME= zynaddsubfx
DISTVERSION= 3.0.6
PORTREVISION= 2
PORTREVISION= 3
PORTEPOCH= 2
CATEGORIES= audio

Expand Down
11 changes: 11 additions & 0 deletions audio/zynaddsubfx/files/patch-rtosc_src_cpp_savefile.cpp
@@ -0,0 +1,11 @@
--- rtosc/src/cpp/savefile.cpp.orig 2021-12-31 15:58:28 UTC
+++ rtosc/src/cpp/savefile.cpp
@@ -534,7 +534,7 @@ int load_from_file(const char* file_content,
n = 0;

sscanf(file_content,
- "%% %128s v%u.%u.%u%n ", appbuf, &vma, &vmi, &vre, &n);
+ "%% %127s v%u.%u.%u%n ", appbuf, &vma, &vmi, &vre, &n);
if(n <= 0 || strcmp(appbuf, appname) || vma > 255 || vmi > 255 || vre > 255)
return -bytes_read-1;

11 changes: 11 additions & 0 deletions audio/zynaddsubfx/files/patch-src_Effects_Distorsion.cpp
@@ -0,0 +1,11 @@
--- src/Effects/Distorsion.cpp.orig 2022-01-22 01:46:21 UTC
+++ src/Effects/Distorsion.cpp
@@ -75,7 +75,7 @@ rtosc::Ports Distorsion::ports = {

for(int i=0; i<128; ++i)
buffer[i] = 2*(i/128.0)-1;
- memcpy(orig, buffer, sizeof(float_t)*128);
+ memcpy(orig, buffer, sizeof(buffer));

waveShapeSmps(sizeof(buffer)/sizeof(buffer[0]), buffer,
dd.Ptype + 1, dd.Pdrive, dd.Poffset, dd.Pfuncpar);
11 changes: 11 additions & 0 deletions audio/zynaddsubfx/files/patch-src_Synth_ADnote.cpp
@@ -0,0 +1,11 @@
--- src/Synth/ADnote.cpp.orig 2022-01-22 01:46:21 UTC
+++ src/Synth/ADnote.cpp
@@ -1264,7 +1264,7 @@ inline void ADnote::ComputeVoiceOscillator_SincInterpo
inline void ADnote::ComputeVoiceOscillator_SincInterpolation(int nvoice)
{
// windowed sinc kernel factor Fs*0.3, rejection 80dB
- const float_t kernel[] = {
+ const float kernel[] = {
0.0010596256917418426f,
0.004273442181254887f,
0.0035466063043375785f,

0 comments on commit 0eb74ba

Please sign in to comment.