Comments (5)
This fixes the issue for me:
diff --git a/src/jackpatch.c b/src/jackpatch.c
index bc9303b..c5d6ec9 100644
--- a/src/jackpatch.c
+++ b/src/jackpatch.c
@@ -328,8 +328,18 @@ connect_path ( struct patch_record *pr )
{
int r = 0;
- char srcport[512]; // This should really be REAL_JACK_PORT_NAME_SIZE, but in the real world not every system and compiler does C99.
- char dstport[512];
+ while (!client_active)
+ {
+ sleep(1);
+ }
+
+ char *srcport = alloca(REAL_JACK_PORT_NAME_SIZE);
+ char *dstport = alloca(REAL_JACK_PORT_NAME_SIZE);
+
+ if (!srcport || !dstport)
+ {
+ return;
+ }
snprintf( srcport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->src.client, pr->src.port );
snprintf( dstport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->dst.client, pr->dst.port );
from new-session-manager.
if pipewire crashes and real jack does not, we should fix pipewire side instead of trying to mitigate the issues.
where does the overflow happen?
from new-session-manager.
jackpatch crashes, it's obviously the clients fault, the line number is in the GDB log.
connect_path
on pipewire-jack is obviously called before REAL_JACK_PORT_NAME_SIZE
is set, so snprintf tries to write into a buffer of size 0/unknown.
jack_port_name_size
should be called before jack_activate
, this fixes the issue for me.
diff --git a/src/jackpatch.c b/src/jackpatch.c
index bc9303b..20a826e 100644
--- a/src/jackpatch.c
+++ b/src/jackpatch.c
@@ -61,7 +61,7 @@ int nsm_is_active;
char *project_file;
-int REAL_JACK_PORT_NAME_SIZE; //defined after jack client activated
+int REAL_JACK_PORT_NAME_SIZE = 0; //defined after jack client activated
#undef VERSION
#define APP_TITLE "JACKPatch"
@@ -328,8 +328,18 @@ connect_path ( struct patch_record *pr )
{
int r = 0;
- char srcport[512]; // This should really be REAL_JACK_PORT_NAME_SIZE, but in the real world not every system and compiler does C99.
- char dstport[512];
+ if (REAL_JACK_PORT_NAME_SIZE == 0)
+ {
+ return;
+ }
+
+ char *srcport = alloca(REAL_JACK_PORT_NAME_SIZE);
+ char *dstport = alloca(REAL_JACK_PORT_NAME_SIZE);
+
+ if (!srcport || !dstport)
+ {
+ return;
+ }
snprintf( srcport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->src.client, pr->src.port );
snprintf( dstport, REAL_JACK_PORT_NAME_SIZE, "%s:%s", pr->dst.client, pr->dst.port );
@@ -733,9 +743,9 @@ maybe_activate_jack_client ( void )
{
if ( ! client_active )
{
+ REAL_JACK_PORT_NAME_SIZE = jack_port_name_size(); //global. This is client+port+1. 64 + 256 + 1 = 321 on Linux.
jack_activate( client );
client_active = 1;
- REAL_JACK_PORT_NAME_SIZE = jack_port_name_size(); //global. This is client+port+1. 64 + 256 + 1 = 321 on Linux.
}
}
from new-session-manager.
ok that part makes sense. but there is no need to change the stack array into alloca, that is an unrelated change.
I have seen issues before due to the use of alloca, as it is not very portable. even its own documentation recommends to not use it. the old code with a fixed 512 array didnt cause any harm there.
from new-session-manager.
The changes are related, they both concern 'REAL_JACK_PORT_NAME_SIZE'. If a fixed buffer size of 512 bytes is ok (which I don't think it is), then there is no need for 'REAL_JACK_PORT_NAME_SIZE' in the first place and you can just use 'snprintf(buf, sizeof(buf), ...)'.
If 'alloca' is not portable, just use an 'malloc'.
from new-session-manager.
Related Issues (20)
- sigkill HOT 5
- Use of pidfiles HOT 14
- server warning sessions folder HOT 2
- snprintf buffer overflow after f42b8e3aac with pipewire versions containing 0e847c97 HOT 1
- Change code to not depend on GNU compiler extensions
- Announce to running server, send also gui hidden/shown & dirty status HOT 1
- jackpatch fork rename
- Nsm-proxy fork rename
- non-session-manager gui incompatibility
- jackpatch, nsm-proxy, ... sends error messages to stdout
- Blocking dialogs from clients
- Clients should send errors to stderr
- Clients should use black/white for logging messages
- launch error, use of client labels
- Two NSM related keys for Desktop files HOT 2
- New extensions shouldn't use the /nsm prefix in the osc address HOT 2
- Documentation for "New" stuff HOT 4
- C shared or static library 'fltk' not found HOT 3
- Does not compile on Alpine (musl)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from new-session-manager.