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]
Message-ID: <20240211010441.8262-1-stephen@networkplumber.org>
Date: Sat, 10 Feb 2024 17:04:23 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: liuhangbin@...il.com,
	jhs@...atatu.com,
	Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2] tc: u32: check return value from snprintf

Add assertion to check for case of snprintf failing (bad format?)
or buffer getting full.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 tc/f_u32.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tc/f_u32.c b/tc/f_u32.c
index 913ec1de435d..8a2413103906 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -7,6 +7,7 @@
  *
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -87,6 +88,7 @@ static char *sprint_u32_handle(__u32 handle, char *buf)
 	if (htid) {
 		int l = snprintf(b, bsize, "%x:", htid>>20);
 
+		assert(l > 0 && l < bsize);
 		bsize -= l;
 		b += l;
 	}
@@ -94,12 +96,14 @@ static char *sprint_u32_handle(__u32 handle, char *buf)
 		if (hash) {
 			int l = snprintf(b, bsize, "%x", hash);
 
+			assert(l > 0 && l < bsize);
 			bsize -= l;
 			b += l;
 		}
 		if (nodeid) {
 			int l = snprintf(b, bsize, ":%x", nodeid);
 
+			assert(l > 0 && l < bsize);
 			bsize -= l;
 			b += l;
 		}
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ