Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH nft] gmputil: assert length is non-zero
@ 2019-08-14  8:20 Pablo Neira Ayuso
  0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2019-08-14  8:20 UTC (permalink / raw)
  To: netfilter-devel; +Cc: fw

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  8:20 [PATCH nft] gmputil: assert length is non-zero Pablo Neira Ayuso

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org netfilter-devel@archiver.kernel.org
	public-inbox-index netfilter-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox