naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0120-ipxfrm-Replace-STRBUF_CAT-macro-with-strlcat.patch

36cfb7
From 65d69021e5b8998cec1e7a13b8b297bfc606f9fd Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Mon, 29 Apr 2019 20:09:12 +0200
36cfb7
Subject: [PATCH] ipxfrm: Replace STRBUF_CAT macro with strlcat()
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
36cfb7
Upstream Status: iproute2.git commit 44cc6c792a650
36cfb7
36cfb7
commit 44cc6c792a6503e024f042c65f35cd44b3283b20
36cfb7
Author: Phil Sutter <phil@nwl.cc>
36cfb7
Date:   Fri Sep 1 18:52:54 2017 +0200
36cfb7
36cfb7
    ipxfrm: Replace STRBUF_CAT macro with strlcat()
36cfb7
36cfb7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
36cfb7
---
36cfb7
 ip/ipxfrm.c | 21 +++++----------------
36cfb7
 1 file changed, 5 insertions(+), 16 deletions(-)
36cfb7
36cfb7
diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
36cfb7
index b0cfac178f8bc..df72a0c0bf88e 100644
36cfb7
--- a/ip/ipxfrm.c
36cfb7
+++ b/ip/ipxfrm.c
36cfb7
@@ -40,17 +40,6 @@
36cfb7
 #include "ip_common.h"
36cfb7
 
36cfb7
 #define STRBUF_SIZE	(128)
36cfb7
-#define STRBUF_CAT(buf, str) \
36cfb7
-	do { \
36cfb7
-		int rest = sizeof(buf) - 1 - strlen(buf); \
36cfb7
-		if (rest > 0) { \
36cfb7
-			int len = strlen(str); \
36cfb7
-			if (len > rest) \
36cfb7
-				len = rest; \
36cfb7
-			strncat(buf, str, len); \
36cfb7
-			buf[sizeof(buf) - 1] = '\0'; \
36cfb7
-		} \
36cfb7
-	} while (0);
36cfb7
 
36cfb7
 struct xfrm_filter filter;
36cfb7
 
36cfb7
@@ -883,8 +872,8 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,
36cfb7
 			   prefix, title);
36cfb7
 
36cfb7
 	if (prefix)
36cfb7
-		STRBUF_CAT(buf, prefix);
36cfb7
-	STRBUF_CAT(buf, "\t");
36cfb7
+		strlcat(buf, prefix, sizeof(buf));
36cfb7
+	strlcat(buf, "\t", sizeof(buf));
36cfb7
 
36cfb7
 	fputs(buf, fp);
36cfb7
 	fprintf(fp, "replay-window %u ", xsinfo->replay_window);
36cfb7
@@ -925,7 +914,7 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,
36cfb7
 		char sbuf[STRBUF_SIZE];
36cfb7
 
36cfb7
 		memcpy(sbuf, buf, sizeof(sbuf));
36cfb7
-		STRBUF_CAT(sbuf, "sel ");
36cfb7
+		strlcat(sbuf, "sel ", sizeof(sbuf));
36cfb7
 
36cfb7
 		xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, sbuf);
36cfb7
 	}
36cfb7
@@ -973,8 +962,8 @@ void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo,
36cfb7
 	}
36cfb7
 
36cfb7
 	if (prefix)
36cfb7
-		STRBUF_CAT(buf, prefix);
36cfb7
-	STRBUF_CAT(buf, "\t");
36cfb7
+		strlcat(buf, prefix, sizeof(buf));
36cfb7
+	strlcat(buf, "\t", sizeof(buf));
36cfb7
 
36cfb7
 	fputs(buf, fp);
36cfb7
 	if (xpinfo->dir >= XFRM_POLICY_MAX) {
36cfb7
-- 
e138d9
2.21.0
36cfb7