]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: seq: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:05:45 +0000 (12:05 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:51:08 +0000 (09:51 +0200)
Use a safer function strscpy() instead of strcpy() for copying to
arrays.

Only idiomatic code replacement, and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250710100727.22653-4-tiwai@suse.de
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_midi.c
sound/core/seq/seq_system.c
sound/core/seq/seq_ump_client.c
sound/core/seq/seq_virmidi.c

index e6d7d83ed0e772adcd2de10931caab96d7f6ceed..973f057eb731f4cc15759bdad0a6aa47bf5ccb02 100644 (file)
@@ -79,7 +79,7 @@ snd_seq_oss_create_client(void)
        system_client = rc;
 
        /* create announcement receiver port */
-       strcpy(port->name, "Receiver");
+       strscpy(port->name, "Receiver");
        port->addr.client = system_client;
        port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
        port->type = 0;
@@ -347,7 +347,7 @@ alloc_seq_queue(struct seq_oss_devinfo *dp)
        memset(&qinfo, 0, sizeof(qinfo));
        qinfo.owner = system_client;
        qinfo.locked = 1;
-       strcpy(qinfo.name, "OSS Sequencer Emulation");
+       strscpy(qinfo.name, "OSS Sequencer Emulation");
        rc = call_ctl(SNDRV_SEQ_IOCTL_CREATE_QUEUE, &qinfo);
        if (rc < 0)
                return rc;
index 880240924bfd0526a61b991f261b49d12253e601..aa9c956d258196c99ae991d619c31d98bd9651fe 100644 (file)
@@ -1256,7 +1256,7 @@ static void get_client_info(struct snd_seq_client *cptr,
 
        /* fill the info fields */
        info->type = cptr->type;
-       strcpy(info->name, cptr->name);
+       strscpy(info->name, cptr->name);
        info->filter = cptr->filter;
        info->event_lost = cptr->event_lost;
        memcpy(info->event_filter, cptr->event_filter, 32);
index ba52a77eda3828a44e1ab9da53c78d4e968b5ab7..581e138a3115923c89fb99f56c1a3bdaf3aa71eb 100644 (file)
@@ -344,7 +344,7 @@ snd_seq_midisynth_probe(struct device *_dev)
                        info->stream = SNDRV_RAWMIDI_STREAM_INPUT;
                info->subdevice = p;
                if (snd_rawmidi_info_select(card, info) >= 0)
-                       strcpy(port->name, info->subname);
+                       strscpy(port->name, info->subname);
                if (! port->name[0]) {
                        if (info->name[0]) {
                                if (ports > 1)
index 853920f79016dfc66955414b7b87f058517b407f..5b5603e5970b24f68ffdbb26b8c1eb44d7d95e12 100644 (file)
@@ -146,7 +146,7 @@ int __init snd_seq_system_client_init(void)
        }
 
        /* register timer */
-       strcpy(port->name, "Timer");
+       strscpy(port->name, "Timer");
        port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* accept queue control */
        port->capability |= SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast */
        port->kernel = &pcallbacks;
@@ -160,7 +160,7 @@ int __init snd_seq_system_client_init(void)
                goto error_port;
 
        /* register announcement port */
-       strcpy(port->name, "Announce");
+       strscpy(port->name, "Announce");
        port->capability = SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast only */
        pcallbacks.event_input = NULL;
        pcallbacks.subscribe = sys_announce_subscribe;
index 1255351b59ce1ac5639d3ebb77735c040b16346b..27247babb16deebfbc3c9a57bf1ebc1252bf0152 100644 (file)
@@ -310,7 +310,7 @@ static int create_ump_endpoint_port(struct seq_ump_client *client)
                SNDRV_SEQ_PORT_TYPE_HARDWARE |
                SNDRV_SEQ_PORT_TYPE_PORT;
        port->midi_channels = 16;
-       strcpy(port->name, "MIDI 2.0");
+       strscpy(port->name, "MIDI 2.0");
        memset(&pcallbacks, 0, sizeof(pcallbacks));
        pcallbacks.owner = THIS_MODULE;
        pcallbacks.private_data = client;
index b4672613c26136adf778cde4a72e7274abcddd18..9e7fd4993a108595ef6591789dfedd2349ad0459 100644 (file)
@@ -497,7 +497,7 @@ int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmi
                              &rmidi);
        if (err < 0)
                return err;
-       strcpy(rmidi->name, rmidi->id);
+       strscpy(rmidi->name, rmidi->id);
        rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
        if (rdev == NULL) {
                snd_device_free(card, rmidi);