naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

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

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