[alsa-devel] [PATCH - alsa-lib 1/1] Fix for snd_seq_parse_address()
From: Pedro Lopez-Cabanillas pedro.lopez.cabanillas@gmail.com
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@gmail.com --- 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; }
On Thu, 22 Apr 2010, pedro.lopez.cabanillas@gmail.com wrote:
From: Pedro Lopez-Cabanillas pedro.lopez.cabanillas@gmail.com
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 perex@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc.
participants (2)
-
Jaroslav Kysela
-
pedro.lopez.cabanillas@gmail.com