Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: seq: Use safer strscpy() instead of strcpy()

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

+8 -8
+2 -2
sound/core/seq/oss/seq_oss_init.c
··· 79 79 system_client = rc; 80 80 81 81 /* create announcement receiver port */ 82 - strcpy(port->name, "Receiver"); 82 + strscpy(port->name, "Receiver"); 83 83 port->addr.client = system_client; 84 84 port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */ 85 85 port->type = 0; ··· 347 347 memset(&qinfo, 0, sizeof(qinfo)); 348 348 qinfo.owner = system_client; 349 349 qinfo.locked = 1; 350 - strcpy(qinfo.name, "OSS Sequencer Emulation"); 350 + strscpy(qinfo.name, "OSS Sequencer Emulation"); 351 351 rc = call_ctl(SNDRV_SEQ_IOCTL_CREATE_QUEUE, &qinfo); 352 352 if (rc < 0) 353 353 return rc;
+1 -1
sound/core/seq/seq_clientmgr.c
··· 1256 1256 1257 1257 /* fill the info fields */ 1258 1258 info->type = cptr->type; 1259 - strcpy(info->name, cptr->name); 1259 + strscpy(info->name, cptr->name); 1260 1260 info->filter = cptr->filter; 1261 1261 info->event_lost = cptr->event_lost; 1262 1262 memcpy(info->event_filter, cptr->event_filter, 32);
+1 -1
sound/core/seq/seq_midi.c
··· 344 344 info->stream = SNDRV_RAWMIDI_STREAM_INPUT; 345 345 info->subdevice = p; 346 346 if (snd_rawmidi_info_select(card, info) >= 0) 347 - strcpy(port->name, info->subname); 347 + strscpy(port->name, info->subname); 348 348 if (! port->name[0]) { 349 349 if (info->name[0]) { 350 350 if (ports > 1)
+2 -2
sound/core/seq/seq_system.c
··· 146 146 } 147 147 148 148 /* register timer */ 149 - strcpy(port->name, "Timer"); 149 + strscpy(port->name, "Timer"); 150 150 port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* accept queue control */ 151 151 port->capability |= SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast */ 152 152 port->kernel = &pcallbacks; ··· 160 160 goto error_port; 161 161 162 162 /* register announcement port */ 163 - strcpy(port->name, "Announce"); 163 + strscpy(port->name, "Announce"); 164 164 port->capability = SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast only */ 165 165 pcallbacks.event_input = NULL; 166 166 pcallbacks.subscribe = sys_announce_subscribe;
+1 -1
sound/core/seq/seq_ump_client.c
··· 310 310 SNDRV_SEQ_PORT_TYPE_HARDWARE | 311 311 SNDRV_SEQ_PORT_TYPE_PORT; 312 312 port->midi_channels = 16; 313 - strcpy(port->name, "MIDI 2.0"); 313 + strscpy(port->name, "MIDI 2.0"); 314 314 memset(&pcallbacks, 0, sizeof(pcallbacks)); 315 315 pcallbacks.owner = THIS_MODULE; 316 316 pcallbacks.private_data = client;
+1 -1
sound/core/seq/seq_virmidi.c
··· 497 497 &rmidi); 498 498 if (err < 0) 499 499 return err; 500 - strcpy(rmidi->name, rmidi->id); 500 + strscpy(rmidi->name, rmidi->id); 501 501 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); 502 502 if (rdev == NULL) { 503 503 snd_device_free(card, rmidi);