Blame SOURCES/libiptc-Simplify-alloc_handle-function-signature.patch

9a3fa7
From e64b48b46cec83203ff8de80a1c56be2c40b2c7d Mon Sep 17 00:00:00 2001
9a3fa7
From: Phil Sutter <psutter@redhat.com>
9a3fa7
Date: Fri, 15 Mar 2019 17:50:10 +0100
9a3fa7
Subject: [PATCH] libiptc: Simplify alloc_handle() function signature
9a3fa7
9a3fa7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1525980
9a3fa7
Upstream Status: iptables commit 22ef371abeeec
9a3fa7
9a3fa7
commit 22ef371abeeec789bb6a701352dcb961556595c2
9a3fa7
Author: Phil Sutter <phil@nwl.cc>
9a3fa7
Date:   Wed Sep 19 15:16:53 2018 +0200
9a3fa7
9a3fa7
    libiptc: Simplify alloc_handle() function signature
9a3fa7
9a3fa7
    This change originated from covscan complaining about the strcpy() call
9a3fa7
    with an unknown size source buffer. But in fact, the size is known (and
9a3fa7
    equal to the destination size), so pass a pointer to STRUCT_GETINFO to
9a3fa7
    alloc_handle() instead of it's fields separately. Hopefully this will
9a3fa7
    silence covscan.
9a3fa7
9a3fa7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
9a3fa7
    Signed-off-by: Florian Westphal <fw@strlen.de>
9a3fa7
9a3fa7
Signed-off-by: Phil Sutter <psutter@redhat.com>
9a3fa7
---
9a3fa7
 libiptc/libiptc.c | 14 +++++++-------
9a3fa7
 1 file changed, 7 insertions(+), 7 deletions(-)
9a3fa7
9a3fa7
diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
9a3fa7
index 1f61fde53f1db..f6a9862ea9f4d 100644
9a3fa7
--- a/libiptc/libiptc.c
9a3fa7
+++ b/libiptc/libiptc.c
9a3fa7
@@ -1269,7 +1269,7 @@ static int iptcc_compile_table(struct xtc_handle *h, STRUCT_REPLACE *repl)
9a3fa7
 
9a3fa7
 /* Allocate handle of given size */
9a3fa7
 static struct xtc_handle *
9a3fa7
-alloc_handle(const char *tablename, unsigned int size, unsigned int num_rules)
9a3fa7
+alloc_handle(STRUCT_GETINFO *infop)
9a3fa7
 {
9a3fa7
 	struct xtc_handle *h;
9a3fa7
 
9a3fa7
@@ -1280,14 +1280,14 @@ alloc_handle(const char *tablename, unsigned int size, unsigned int num_rules)
9a3fa7
 	}
9a3fa7
 	memset(h, 0, sizeof(*h));
9a3fa7
 	INIT_LIST_HEAD(&h->chains);
9a3fa7
-	strcpy(h->info.name, tablename);
9a3fa7
+	strcpy(h->info.name, infop->name);
9a3fa7
 
9a3fa7
-	h->entries = malloc(sizeof(STRUCT_GET_ENTRIES) + size);
9a3fa7
+	h->entries = malloc(sizeof(STRUCT_GET_ENTRIES) + infop->size);
9a3fa7
 	if (!h->entries)
9a3fa7
 		goto out_free_handle;
9a3fa7
 
9a3fa7
-	strcpy(h->entries->name, tablename);
9a3fa7
-	h->entries->size = size;
9a3fa7
+	strcpy(h->entries->name, infop->name);
9a3fa7
+	h->entries->size = infop->size;
9a3fa7
 
9a3fa7
 	return h;
9a3fa7
 
9a3fa7
@@ -1336,8 +1336,8 @@ retry:
9a3fa7
 	DEBUGP("valid_hooks=0x%08x, num_entries=%u, size=%u\n",
9a3fa7
 		info.valid_hooks, info.num_entries, info.size);
9a3fa7
 
9a3fa7
-	if ((h = alloc_handle(info.name, info.size, info.num_entries))
9a3fa7
-	    == NULL) {
9a3fa7
+	h = alloc_handle(&info;;
9a3fa7
+	if (h == NULL) {
9a3fa7
 		close(sockfd);
9a3fa7
 		return NULL;
9a3fa7
 	}
9a3fa7
-- 
9a3fa7
2.21.0
9a3fa7