public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH] Do not pass null pointer to freeaddrinfo()
Date: Sat,  1 Dec 2018 10:16:21 -0800	[thread overview]
Message-ID: <20181201181621.7268-2-raj.khem@gmail.com> (raw)
In-Reply-To: <20181201181621.7268-1-raj.khem@gmail.com>

Passing null pointer as input parameter to freeaddrinfo() is undefined
behaviour, some libcs e.g. glibc might just call free() which does
accept null pointer but other libcs e.g. musl might not and instead
cause the program to segfault. Therefore do not rely on undefined
behaviour instead make it deterministic

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 support/export/client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: nfs-utils-2.3.2/support/export/client.c
===================================================================
--- nfs-utils-2.3.2.orig/support/export/client.c
+++ nfs-utils-2.3.2/support/export/client.c
@@ -309,7 +309,8 @@ client_lookup(char *hname, int canonical
 		init_addrlist(clp, ai);
 
 out:
-	freeaddrinfo(ai);
+	if (ai)
+		freeaddrinfo(ai);
 	return clp;
 }
 

      reply	other threads:[~2018-12-01 18:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-01 18:16 [PATCH] cacheio: use intmax_t for formatted IO Khem Raj
2018-12-01 18:16 ` Khem Raj [this message]

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=20181201181621.7268-2-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=linux-nfs@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