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-next>] [day] [month] [year] [list]
Date:	Sun,  5 Oct 2014 23:46:03 +0200
From:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To:	David Airlie <airlied@...ux.ie>, dri-devel@...ts.freedesktop.org
Cc:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] gpu: drm: drm_dp_mst_topology.c:  Fix improper use of strncat.

I have now eliminate the need to use the temporary string,
and therefore also the use of strncat.
And I think this code is clearer and more effective.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
 drivers/gpu/drm/drm_dp_mst_topology.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index ac3c273..c3f6571 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -997,17 +997,18 @@ static void build_mst_prop_path(struct drm_dp_mst_port *port,
 				struct drm_dp_mst_branch *mstb,
 				char *proppath)
 {
-	int i;
-	char temp[8];
-	snprintf(proppath, 255, "mst:%d", mstb->mgr->conn_base_id);
+	int i, len;
+	static const int proppath_len = 255;
+	memset(proppath, 0, proppath_len);
+	len = snprintf(proppath, proppath_len, "mst:%d", mstb->mgr->conn_base_id);
 	for (i = 0; i < (mstb->lct - 1); i++) {
 		int shift = (i % 2) ? 0 : 4;
 		int port_num = mstb->rad[i / 2] >> shift;
-		snprintf(temp, 8, "-%d", port_num);
-		strncat(proppath, temp, 255);
+		len += snprintf(&proppath[(len < proppath_len ? len : 0)],
+						proppath_len - len, "-%d", port_num);
 	}
-	snprintf(temp, 8, "-%d", port->port_num);
-	strncat(proppath, temp, 255);
+	snprintf(&proppath[(len < proppath_len ? len : 0)], proppath_len - len,
+					"-%d", port->port_num);
 }
 
 static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ