[PATCH - alsa-lib 1/1] Fix for snd_seq_parse_address()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Pedro Lopez-Cabanillas <pedro.lopez.cabanillas@xxxxxxxxx>

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.

Signed-off-by: Pedro Lopez-Cabanillas <pedro.lopez.cabanillas@xxxxxxxxx>
---
 src/seq/seqmid.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/seq/seqmid.c b/src/seq/seqmid.c
index 86a4970..894c3a2 100644
--- a/src/seq/seqmid.c
+++ b/src/seq/seqmid.c
@@ -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;
 			}
-- 
1.6.4.2

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux