All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: steved@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 2/2] libexport.a: export_find() should handle address parsing errors
Date: Thu, 15 Apr 2010 11:25:25 -0400	[thread overview]
Message-ID: <20100415152524.4716.57643.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>

An address mask parsing error can cause client_init(), and therefore
client_dup(), to make our process exit suddenly.  Soon we want to add
more complex address parsing in client_init(), so we need this
interface to be a little more robust.

Since export_find() can return NULL in some cases, it can handle NULL
returns from its subroutines if an address parsing error occurs, or if
memory is exhausted.  Allow for client_dup() to return NULL instead of
exiting sideways.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 support/export/export.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/support/export/export.c b/support/export/export.c
index ddc8a84..3e4da69 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -129,6 +129,10 @@ export_dup(nfs_export *exp, struct hostent *hp)
 	if (exp->m_export.e_hostname)
 		new->m_export.e_hostname = xstrdup(exp->m_export.e_hostname);
 	clp = client_dup(exp->m_client, hp);
+	if (clp == NULL) {
+		export_free(new);
+		return NULL;
+	}
 	clp->m_count++;
 	new->m_client = clp;
 	new->m_mayexport = exp->m_mayexport;


  parent reply	other threads:[~2010-04-15 15:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15 15:25 [PATCH 0/2] Handle address parsing errors in export_find() Chuck Lever
     [not found] ` <20100415152401.4716.83632.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-15 15:25   ` [PATCH 1/2] libexport.a: Add export_free() Chuck Lever
2010-04-15 15:25   ` Chuck Lever [this message]
2010-04-16 17:05   ` [PATCH 0/2] Handle address parsing errors in export_find() Steve Dickson

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=20100415152524.4716.57643.stgit@localhost.localdomain \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.