[PATCH 2/2] libexport.a: export_find() should handle address parsing errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

 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;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux