2003-05-25 18:09:43

by Ben Collins

[permalink] [raw]
Subject: [PATCH] Fix snd_seq_queue_find_name()

While going through sound/ for strncpy replacing, I came across this
routine:

/* return the (first) queue matching with the specified name */
queue_t *snd_seq_queue_find_name(char *name)
{
int i;
queue_t *q;

for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
if ((q = queueptr(i)) != NULL) {
if (strncpy(q->name, name, sizeof(q->name)) == 0)
return q;
queuefree(q);
}
}
return NULL;
}


I'm _really_ sure that they meant to use strncmp() here instead. Patch
below fixes it.


Index: sound/core/seq/seq_queue.c
===================================================================
--- sound/core/seq/seq_queue.c (revision 10041)
+++ sound/core/seq/seq_queue.c (working copy)
@@ -241,7 +241,7 @@

for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
if ((q = queueptr(i)) != NULL) {
- if (strncpy(q->name, name, sizeof(q->name)) == 0)
+ if (strncmp(q->name, name, sizeof(q->name)) == 0)
return q;
queuefree(q);
}