netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Maciej Żenczykowski" <zenczykowski@gmail.com>
To: "Maciej Żenczykowski" <maze@google.com>,
	"Pablo Neira Ayuso" <pablo@netfilter.org>,
	"Florian Westphal" <fw@strlen.de>
Cc: Linux Network Development Mailing List <netdev@vger.kernel.org>,
	Netfilter Development Mailing List 
	<netfilter-devel@vger.kernel.org>
Subject: [PATCH] libiptc.c: pragma disable a gcc compiler warning
Date: Mon, 11 May 2020 14:34:04 -0700	[thread overview]
Message-ID: <20200511213404.248715-1-zenczykowski@gmail.com> (raw)

From: Maciej Żenczykowski <maze@google.com>

Fixes:
  In file included from libip4tc.c:113:
  In function ‘iptcc_compile_chain’,
      inlined from ‘iptcc_compile_table’ at libiptc.c:1246:13,
      inlined from ‘iptc_commit’ at libiptc.c:2575:8,
      inlined from ‘iptc_commit’ at libiptc.c:2513:1:
  libiptc.c:1172:2: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
   1172 |  memcpy(&foot->e.counters, &c->counters, sizeof(STRUCT_COUNTERS));
        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../include/libiptc/libiptc.h:12,
                   from libip4tc.c:29:
  libiptc.c: In function ‘iptc_commit’:
  ../include/linux/netfilter_ipv4/ip_tables.h:202:19: note: at offset 0 to object ‘entries’ with size 0 declared here
    202 |  struct ipt_entry entries[0];
        |                   ^~~~~~~

Which was found via compilation on Fedora 32.

Test: builds without warnings
Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 libiptc/libiptc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c
index 58882015..1a92b267 100644
--- a/libiptc/libiptc.c
+++ b/libiptc/libiptc.c
@@ -1169,7 +1169,10 @@ static int iptcc_compile_chain(struct xtc_handle *h, STRUCT_REPLACE *repl, struc
 	else
 		foot->target.verdict = RETURN;
 	/* set policy-counters */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
 	memcpy(&foot->e.counters, &c->counters, sizeof(STRUCT_COUNTERS));
+#pragma GCC diagnostic pop
 
 	return 0;
 }
-- 
2.26.2.645.ge9eca65c58-goog


             reply	other threads:[~2020-05-11 21:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 21:34 Maciej Żenczykowski [this message]
2020-05-14 17:58 ` [PATCH] libiptc.c: pragma disable a gcc compiler warning Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200511213404.248715-1-zenczykowski@gmail.com \
    --to=zenczykowski@gmail.com \
    --cc=fw@strlen.de \
    --cc=maze@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).