Skip to contentSkip to conversation

recent change in seqmid.c is broken?

DISCUSSION Takashi Iwai 2 participants 4 messages Apr 14, 2025 – Apr 15, 2025

lore
Share & tools
lore
#0 lore raw

Hi Jaroslav,

I'm afraid that your recent fix for alsa-lib commit a4e47461eca1 doesn't work as expected:

```
@@ -664,15 +663,11 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
                                break;
                        }
 
-                       if (!*bp->name)
+                       if (bp->name[0] == '\0')
                                continue;
-                       len = strlen(blknames);
-                       if (len)
-                               snprintf(blknames + len, sizeof(blknames) - len,
-                                        ", %s", bp->name);
-                       else
-                               snd_strlcpy(blknames, (const char *)bp->name,
-                                           sizeof(blknames));
+                       if (blknames[0])
+                               snd_strlcpy(blknames, ", ", sizeof(blknames));
+                       snd_strlcpy(blknames, (const char *)bp->name, sizeof(blknames));
                }
 
                if (!*blknames)
```

The original code appended the new bp->name string with the prefix of ", " if blknames is already present, but the new code looks as if it overwrites onto blknames with strlcpy() from scratch for each bp->name.

FWIW, the code there used to be with strlcat(), but it was rewritten in the way above because strlcat() isn't always available in commit d9694398130c.

thanks,

Takashi

#1 lore raw
Quoted 28 lines · Takashi Iwai

Hi Jaroslav,

I'm afraid that your recent fix for alsa-lib commit a4e47461eca1 doesn't work as expected:

```

(quoted diff) +4 -8
@@ -664,15 +663,11 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
                                 break;
                         }
 
-                       if (!*bp->name)
+                       if (bp->name[0] == '\0')
                                 continue;
-                       len = strlen(blknames);
-                       if (len)
-                               snprintf(blknames + len, sizeof(blknames) - len,
-                                        ", %s", bp->name);
-                       else
-                               snd_strlcpy(blknames, (const char *)bp->name,
-                                           sizeof(blknames));
+                       if (blknames[0])
+                               snd_strlcpy(blknames, ", ", sizeof(blknames));
+                       snd_strlcpy(blknames, (const char *)bp->name, sizeof(blknames));
                 }
 
                 if (!*blknames)

```

Quoted 8 lines

The original code appended the new bp->name string with the prefix of ", " if blknames is already present, but the new code looks as if it overwrites onto blknames with strlcpy() from scratch for each bp->name.

FWIW, the code there used to be with strlcat(), but it was rewritten in the way above because strlcat() isn't always available in commit d9694398130c.

Oops.... I am at the end of 1.2.14 release procedure.

I'm trying to put the correct fix, could you check quickly latest two commits?

Thanks,
Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#2 lore raw
Quoted 34 lines · Jaroslav Kysela
Quoted 33 lines · Takashi Iwai

Hi Jaroslav,

I'm afraid that your recent fix for alsa-lib commit a4e47461eca1 doesn't work as expected:

```

(quoted diff) +4 -8
@@ -664,15 +663,11 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
                                  break;
                          }
 
-                       if (!*bp->name)
+                       if (bp->name[0] == '\0')
                                  continue;
-                       len = strlen(blknames);
-                       if (len)
-                               snprintf(blknames + len, sizeof(blknames) - len,
-                                        ", %s", bp->name);
-                       else
-                               snd_strlcpy(blknames, (const char *)bp->name,
-                                           sizeof(blknames));
+                       if (blknames[0])
+                               snd_strlcpy(blknames, ", ", sizeof(blknames));
+                       snd_strlcpy(blknames, (const char *)bp->name, sizeof(blknames));
                  }
 
                  if (!*blknames)

```

The original code appended the new bp->name string with the prefix of ", " if blknames is already present, but the new code looks as if it overwrites onto blknames with strlcpy() from scratch for each bp->name.

Quoted 7 lines
Quoted 3 lines

FWIW, the code there used to be with strlcat(), but it was rewritten in the way above because strlcat() isn't always available in commit d9694398130c.

Oops.... I am at the end of 1.2.14 release procedure.

I'm trying to put the correct fix, could you check quickly latest two commits?

The fix is in 1.2.14 alsa-lib release.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#3 lore raw
In reply to Jaroslav Kysela
Quoted 33 lines · Jaroslav Kysela
Quoted 31 lines · Takashi Iwai

Hi Jaroslav,

I'm afraid that your recent fix for alsa-lib commit a4e47461eca1 doesn't work as expected:

```

(quoted diff) +4 -7
@@ -664,15 +663,11 @@ static void update_group_ports(snd_seq_t *seq, snd_ump_endpoint_info_t *ep)
                                 break;
                         }
  -                       if (!*bp->name)
+                       if (bp->name[0] == '\0')
                                 continue;
-                       len = strlen(blknames);
-                       if (len)
-                               snprintf(blknames + len, sizeof(blknames) - len,
-                                        ", %s", bp->name);
-                       else
-                               snd_strlcpy(blknames, (const char *)bp->name,
-                                           sizeof(blknames));
+                       if (blknames[0])
+                               snd_strlcpy(blknames, ", ", sizeof(blknames));
+                       snd_strlcpy(blknames, (const char *)bp->name, sizeof(blknames));
                 }
                   if (!*blknames)

```

The original code appended the new bp->name string with the prefix of ", " if blknames is already present, but the new code looks as if it overwrites onto blknames with strlcpy() from scratch for each bp->name.

Quoted 7 lines
Quoted 3 lines

FWIW, the code there used to be with strlcat(), but it was rewritten in the way above because strlcat() isn't always available in commit d9694398130c.

Oops.... I am at the end of 1.2.14 release procedure.

I'm trying to put the correct fix, could you check quickly latest two commits?

Looks good to me. Thanks!

Takashi