Skip to contentSkip to conversation

Fix for snd_seq_parse_address()

PATCH Applied [email protected] 2 participants 2 messages Apr 22, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix for snd_seq_parse_address()

From: Pedro Lopez-Cabanillas <[email protected]>

snd_seq_parse_address() uses strncmp() to compare the client name in the string argument with the existing clients, until it finds one name matching the same leading characters. This may produce wrong results when there are two sequencer clients with similar names. For instance, the following procedure produces a wrong result:

1. start KMidimon (http://kmidimon.sf.net)

$ kmidimon &
-->results: Client 128 : "KMidimon" [User]

2. start KMid (http://kmid2.sf.net)

$ kmid &
-->results: Client 129 : "KMid" [User]

3. try to subscribe the output port of KMid to KMidimon

$ aconnect KMid:0 KMidimon:0
--> results:
Client 128 : "KMidimon" [User]
  Port   0 : "KMidimon" (RWe-)
    Connecting To: 20:0, 128:0
    Connected From: 0:1, 128:0
128:0 becomes subscribed to itself. It should be subscribed from 129:0 instead.
---
 src/seq/seqmid.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
src/seq/seqmid.c +2 -1
index 86a4970..894c3a2 100644
@@ -414,7 +414,8 @@ int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *arg)
 			return -EINVAL;
 		cinfo.client = -1;
 		while (snd_seq_query_next_client(seq, &cinfo) >= 0) {
-			if (! strncmp(arg, cinfo.name, len)) {
+			if ((strlen(cinfo.name) == len) &&
+				! strncmp(arg, cinfo.name, len)) {
 				addr->client = cinfo.client;
 				return 0;
 			}
Signature · 1 line
1.6.4.2
#1 lore raw
Quoted 7 lines · On Thu, 22 Apr 2010, [email protected] wrote:

From: Pedro Lopez-Cabanillas <[email protected]>

snd_seq_parse_address() uses strncmp() to compare the client name in the string argument with the existing clients, until it finds one name matching the same leading characters. This may produce wrong results when there are two sequencer clients with similar names. For instance, the following procedure produces a wrong result:

Applied to the alsa-lib repo. Thanks.

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.