lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250830173850.323897-2-nogunix@gmail.com>
Date: Sun, 31 Aug 2025 02:38:49 +0900
From: Masaharu Noguchi <nogunix@...il.com>
To: gregkh@...uxfoundation.org,
	linux-staging@...ts.linux.dev
Cc: vaibhav.sr@...il.com,
	mgreer@...malcreek.com,
	johan@...nel.org,
	elder@...nel.org,
	greybus-dev@...ts.linaro.org,
	florian.fainelli@...adcom.com,
	rjui@...adcom.com,
	sbranden@...adcom.com,
	bcm-kernel-feedback-list@...adcom.com,
	dave.stevenson@...pberrypi.com,
	laurent.pinchart@...asonboard.com,
	hverkuil@...nel.org,
	linux-rpi-kernel@...ts.infradead.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Masaharu Noguchi <nogunix@...il.com>
Subject: [PATCH 1/2] staging: greybus: audio_topology: avoid -Wformat-truncation

    - Fix -Wformat-truncation when prefixing device id to widget/control
      names.
    - Write the prefix with scnprintf() and copy the remainder with
      strscpy().
    - This avoids potential truncation and satisfies W=1 builds in
      drivers/staging/greybus.

Signed-off-by: Masaharu Noguchi <nogunix@...il.com>
---
 drivers/staging/greybus/audio_topology.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 6ca938dca4fd..5bf8b5e29dd8 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -1013,7 +1013,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
 				      struct snd_soc_dapm_widget *dw,
 				      struct gb_audio_widget *w, int *w_size)
 {
-	int i, ret, csize;
+	int i, ret, csize, n;
 	struct snd_kcontrol_new *widget_kctls;
 	struct gb_audio_control *curr;
 	struct gbaudio_control *control, *_control;
@@ -1087,7 +1087,8 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
 
 	/* Prefix dev_id to widget control_name */
 	strscpy(temp_name, w->name, sizeof(temp_name));
-	snprintf(w->name, sizeof(w->name), "GB %d %s", module->dev_id, temp_name);
+	n = scnprintf(w->name, sizeof(w->name), "GB %d ", module->dev_id);
+	strscpy(w->name + n, temp_name, sizeof(w->name) - n);
 
 	switch (w->type) {
 	case snd_soc_dapm_spk:
@@ -1138,7 +1139,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
 static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
 					  struct gb_audio_control *controls)
 {
-	int i, csize, ret;
+	int i, csize, ret, n;
 	struct snd_kcontrol_new *dapm_kctls;
 	struct gb_audio_control *curr;
 	struct gbaudio_control *control, *_control;
@@ -1169,8 +1170,8 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
 		control->id = curr->id;
 		/* Prefix dev_id to widget_name */
 		strscpy(temp_name, curr->name, sizeof(temp_name));
-		snprintf(curr->name, sizeof(curr->name), "GB %d %s", module->dev_id,
-			 temp_name);
+		n = scnprintf(curr->name, sizeof(curr->name), "GB %d ", module->dev_id);
+		strscpy(curr->name + n, temp_name, sizeof(curr->name) - n);
 		control->name = curr->name;
 		if (curr->info.type == GB_AUDIO_CTL_ELEM_TYPE_ENUMERATED) {
 			struct gb_audio_enumerated *gbenum =
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ