netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: fw@strlen.de
Subject: [PATCH nft] gmputil: assert length is non-zero
Date: Wed, 14 Aug 2019 10:20:09 +0200	[thread overview]
Message-ID: <20190814082009.27595-1-pablo@netfilter.org> (raw)

Importing, exporting and byteswapping zero length data should not
happen.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
Probably this helps spot more problems with s390.

 src/gmputil.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/gmputil.c b/src/gmputil.c
index a25f42ee2b64..424a83842b8d 100644
--- a/src/gmputil.c
+++ b/src/gmputil.c
@@ -94,6 +94,8 @@ void *mpz_export_data(void *data, const mpz_t op,
 	enum mpz_word_order order;
 	enum mpz_byte_order endian;
 
+	assert(len > 0);
+
 	switch (byteorder) {
 	case BYTEORDER_BIG_ENDIAN:
 	default:
@@ -118,6 +120,8 @@ void mpz_import_data(mpz_t rop, const void *data,
 	enum mpz_word_order order;
 	enum mpz_byte_order endian;
 
+	assert(len > 0);
+
 	switch (byteorder) {
 	case BYTEORDER_BIG_ENDIAN:
 	default:
@@ -137,6 +141,8 @@ void mpz_switch_byteorder(mpz_t rop, unsigned int len)
 {
 	char data[len];
 
+	assert(len > 0);
+
 	mpz_export_data(data, rop, BYTEORDER_BIG_ENDIAN, len);
 	mpz_import_data(rop, data, BYTEORDER_HOST_ENDIAN, len);
 }
-- 
2.11.0



                 reply	other threads:[~2019-08-14  8:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190814082009.27595-1-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.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).