From f5451d7a63e5cc303b2fc33eda387fba327b6c03 Mon Sep 17 00:00:00 2001 From: huyan Date: Mon, 17 Jun 2019 16:21:44 +0800 Subject: [PATCH] backport fix e_hostname and e_uuid leaks in rpc.mountd --- support/export/xtab.c | 16 ++++++++++++++++ support/nfs/exports.c | 12 +++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/support/export/xtab.c b/support/export/xtab.c index d42eeef..38097e7 100644 --- a/support/export/xtab.c +++ b/support/export/xtab.c @@ -50,6 +50,14 @@ xtab_read(char *xtab, char *lockfn, int is_export) while ((xp = getexportent(is_export==0, 0)) != NULL) { if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) && !(exp = export_create(xp, is_export!=1))) { + if(xp->e_hostname) { + free(xp->e_hostname); + xp->e_hostname=NULL; + } + if(xp->e_uuid) { + free(xp->e_uuid); + xp->e_uuid=NULL; + } continue; } switch (is_export) { @@ -63,6 +71,14 @@ xtab_read(char *xtab, char *lockfn, int is_export) v4root_needed = 0; break; } + if(xp->e_hostname) { + free(xp->e_hostname); + xp->e_hostname=NULL; + } + if(xp->e_uuid) { + free(xp->e_uuid); + xp->e_uuid=NULL; + } } endexportent(); xfunlock(lockid); diff --git a/support/nfs/exports.c b/support/nfs/exports.c index d826ba0..edb5d17 100644 --- a/support/nfs/exports.c +++ b/support/nfs/exports.c @@ -179,8 +179,18 @@ getexportent(int fromkernel, int fromexports) } ee.e_hostname = xstrdup(hostname); - if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) + if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0) { + if(ee.e_hostname) { + xfree(ee.e_hostname); + ee.e_hostname=NULL; + } + if(ee.e_uuid) { + xfree(ee.e_uuid); + ee.e_uuid=NULL; + } + return NULL; + } /* resolve symlinks */ if (realpath(ee.e_path, rpath) != NULL) { -- 1.8.3.1