[PATCH] skl-topology_3627: using sprintf changed to snprintf

From: Natalia Petrova
Date: Fri Feb 17 2023 - 08:15:50 EST


Use snprintf instead of sprintf to avoid buffer overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 2d744ecf2b98 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT")
Signed-off-by: Natalia Petrova <n.petrova@xxxxxxxxxx>
---
sound/soc/intel/skylake/skl-topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index e06eac592da1..ac06926e651d 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -3660,7 +3660,7 @@ static int skl_tplg_complete(struct snd_soc_component *component)

se = (struct soc_enum *)kcontrol->private_value;
texts = dobj->control.dtexts;
- sprintf(chan_text, "c%d", mach->mach_params.dmic_num);
+ snprintf(chan_text, sizeof(chan_text), "c%d", mach->mach_params.dmic_num);

for (i = 0; i < se->items; i++) {
if (strstr(texts[i], chan_text)) {
--
2.34.1