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