Skip to content

Commit 0bdbce2

Browse files
committed
ALSA: hda: 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. Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 0c8e393 commit 0bdbce2

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

sound/hda/codecs/ca0132.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5796,7 +5796,7 @@ static int ca0132_alt_mic_boost_info(struct snd_kcontrol *kcontrol,
57965796
if (uinfo->value.enumerated.item >= MIC_BOOST_NUM_OF_STEPS)
57975797
uinfo->value.enumerated.item = MIC_BOOST_NUM_OF_STEPS - 1;
57985798
sprintf(namestr, "%d %s", (uinfo->value.enumerated.item * 10), sfx);
5799-
strcpy(uinfo->value.enumerated.name, namestr);
5799+
strscpy(uinfo->value.enumerated.name, namestr);
58005800
return 0;
58015801
}
58025802

@@ -5850,7 +5850,7 @@ static int ae5_headphone_gain_info(struct snd_kcontrol *kcontrol,
58505850
sprintf(namestr, "%s %s",
58515851
ae5_headphone_gain_presets[uinfo->value.enumerated.item].name,
58525852
sfx);
5853-
strcpy(uinfo->value.enumerated.name, namestr);
5853+
strscpy(uinfo->value.enumerated.name, namestr);
58545854
return 0;
58555855
}
58565856

@@ -5903,7 +5903,7 @@ static int ae5_sound_filter_info(struct snd_kcontrol *kcontrol,
59035903
uinfo->value.enumerated.item = AE5_SOUND_FILTER_MAX - 1;
59045904
sprintf(namestr, "%s",
59055905
ae5_filter_presets[uinfo->value.enumerated.item].name);
5906-
strcpy(uinfo->value.enumerated.name, namestr);
5906+
strscpy(uinfo->value.enumerated.name, namestr);
59075907
return 0;
59085908
}
59095909

@@ -5952,7 +5952,7 @@ static int ca0132_alt_input_source_info(struct snd_kcontrol *kcontrol,
59525952
uinfo->value.enumerated.items = IN_SRC_NUM_OF_INPUTS;
59535953
if (uinfo->value.enumerated.item >= IN_SRC_NUM_OF_INPUTS)
59545954
uinfo->value.enumerated.item = IN_SRC_NUM_OF_INPUTS - 1;
5955-
strcpy(uinfo->value.enumerated.name,
5955+
strscpy(uinfo->value.enumerated.name,
59565956
in_src_str[uinfo->value.enumerated.item]);
59575957
return 0;
59585958
}
@@ -6004,7 +6004,7 @@ static int ca0132_alt_output_select_get_info(struct snd_kcontrol *kcontrol,
60046004
uinfo->value.enumerated.items = NUM_OF_OUTPUTS;
60056005
if (uinfo->value.enumerated.item >= NUM_OF_OUTPUTS)
60066006
uinfo->value.enumerated.item = NUM_OF_OUTPUTS - 1;
6007-
strcpy(uinfo->value.enumerated.name,
6007+
strscpy(uinfo->value.enumerated.name,
60086008
out_type_str[uinfo->value.enumerated.item]);
60096009
return 0;
60106010
}
@@ -6055,7 +6055,7 @@ static int ca0132_alt_speaker_channel_cfg_get_info(struct snd_kcontrol *kcontrol
60556055
uinfo->value.enumerated.items = items;
60566056
if (uinfo->value.enumerated.item >= items)
60576057
uinfo->value.enumerated.item = items - 1;
6058-
strcpy(uinfo->value.enumerated.name,
6058+
strscpy(uinfo->value.enumerated.name,
60596059
speaker_channel_cfgs[uinfo->value.enumerated.item].name);
60606060
return 0;
60616061
}
@@ -6108,7 +6108,7 @@ static int ca0132_alt_svm_setting_info(struct snd_kcontrol *kcontrol,
61086108
uinfo->value.enumerated.items = NUM_OF_SVM_SETTINGS;
61096109
if (uinfo->value.enumerated.item >= NUM_OF_SVM_SETTINGS)
61106110
uinfo->value.enumerated.item = NUM_OF_SVM_SETTINGS - 1;
6111-
strcpy(uinfo->value.enumerated.name,
6111+
strscpy(uinfo->value.enumerated.name,
61126112
out_svm_set_enum_str[uinfo->value.enumerated.item]);
61136113
return 0;
61146114
}
@@ -6172,7 +6172,7 @@ static int ca0132_alt_eq_preset_info(struct snd_kcontrol *kcontrol,
61726172
uinfo->value.enumerated.items = items;
61736173
if (uinfo->value.enumerated.item >= items)
61746174
uinfo->value.enumerated.item = items - 1;
6175-
strcpy(uinfo->value.enumerated.name,
6175+
strscpy(uinfo->value.enumerated.name,
61766176
ca0132_alt_eq_presets[uinfo->value.enumerated.item].name);
61776177
return 0;
61786178
}
@@ -6229,7 +6229,7 @@ static int ca0132_voicefx_info(struct snd_kcontrol *kcontrol,
62296229
uinfo->value.enumerated.items = items;
62306230
if (uinfo->value.enumerated.item >= items)
62316231
uinfo->value.enumerated.item = items - 1;
6232-
strcpy(uinfo->value.enumerated.name,
6232+
strscpy(uinfo->value.enumerated.name,
62336233
ca0132_voicefx_presets[uinfo->value.enumerated.item].name);
62346234
return 0;
62356235
}

sound/hda/codecs/generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,7 @@ static int in_jack_mode_info(struct snd_kcontrol *kcontrol,
28282828
snd_hda_enum_helper_info(kcontrol, uinfo, hweight32(vref_caps),
28292829
vref_texts);
28302830
/* set the right text */
2831-
strcpy(uinfo->value.enumerated.name,
2831+
strscpy(uinfo->value.enumerated.name,
28322832
vref_texts[get_vref_idx(vref_caps, uinfo->value.enumerated.item)]);
28332833
return 0;
28342834
}
@@ -2941,7 +2941,7 @@ static int hp_mic_jack_mode_info(struct snd_kcontrol *kcontrol,
29412941
text = "Mic In";
29422942
}
29432943

2944-
strcpy(uinfo->value.enumerated.name, text);
2944+
strscpy(uinfo->value.enumerated.name, text);
29452945
return 0;
29462946
}
29472947

sound/hda/codecs/realtek/realtek.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
11301130
switch (action) {
11311131
case HDA_FIXUP_ACT_PRE_PROBE:
11321132
/* override card longname to provide a unique UCM profile */
1133-
strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
1133+
strscpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
11341134
break;
11351135
case HDA_FIXUP_ACT_BUILD:
11361136
/* rename Capture controls depending on the codec */
@@ -1155,7 +1155,7 @@ void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
11551155
switch (action) {
11561156
case HDA_FIXUP_ACT_PRE_PROBE:
11571157
/* override card longname to provide a unique UCM profile */
1158-
strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
1158+
strscpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
11591159
break;
11601160
case HDA_FIXUP_ACT_BUILD:
11611161
/* rename Capture controls depending on the codec */

sound/hda/common/codec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ find_mixer_ctl(struct hda_codec *codec, const char *name, int dev, int idx)
16381638
id.index = idx;
16391639
if (snd_BUG_ON(strlen(name) >= sizeof(id.name)))
16401640
return NULL;
1641-
strcpy(id.name, name);
1641+
strscpy(id.name, name);
16421642
return snd_ctl_find_id(codec->card, &id);
16431643
}
16441644

@@ -3508,7 +3508,7 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux,
35083508
index = uinfo->value.enumerated.item;
35093509
if (index >= imux->num_items)
35103510
index = imux->num_items - 1;
3511-
strcpy(uinfo->value.enumerated.name, imux->items[index].label);
3511+
strscpy(uinfo->value.enumerated.name, imux->items[index].label);
35123512
return 0;
35133513
}
35143514
EXPORT_SYMBOL_GPL(snd_hda_input_mux_info);

sound/hda/controllers/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ static int azx_first_init(struct azx *chip)
20242024
if (azx_acquire_irq(chip, 0) < 0)
20252025
return -EBUSY;
20262026

2027-
strcpy(card->driver, "HDA-Intel");
2027+
strscpy(card->driver, "HDA-Intel");
20282028
strscpy(card->shortname, driver_short_names[chip->driver_type],
20292029
sizeof(card->shortname));
20302030
snprintf(card->longname, sizeof(card->longname),

0 commit comments

Comments
 (0)