Patchwork nfsref: fix a segmentation fault when lookup a junction

login
register
mail settings
Submitter Ditang Chen
Date June 9, 2014, 1:42 a.m.
Message ID <53951109.9030301@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/357280/
State Accepted
Headers show

Comments

Ditang Chen - June 9, 2014, 1:42 a.m.
Can not retrieve FSN with the fsn_uuid when lookup a junction,the entries 
is 1 and the 'tmp' pointer to NULL.

# ls -l
total 8
d--------T 2 root root 4096 Jun  4 07:05 s2
# nsdb-list 
NSDB: ldap.example.net:389
  NCE ou=fedfs,dc=example,dc=net has no FSN records
# nfsref lookup s2
Segmentation fault

(gdb) bt
#0  0x0000000000404eb0 in nfsref_lookup_resolve_fsn (host=0x118d630, fsn_uuid=<optimized out>) at lookup.c:364
#1  nfsref_lookup_nfs_fedfs (junct_path=<optimized out>) at lookup.c:483
#2  0x0000000000403cf9 in main (argc=3, argv=0x7fff69dea5e8) at nfsref.c:181

Signed-off-by: chendt.fnst@cn.fujitsu.com
---
 src/libnsdb/fileserver.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Chuck Lever - June 9, 2014, 4:16 p.m.
Hi Ditang-

On Jun 8, 2014, at 9:42 PM, Ditang Chen <chendt.fnst@cn.fujitsu.com> wrote:

> Can not retrieve FSN with the fsn_uuid when lookup a junction,the entries 
> is 1 and the 'tmp' pointer to NULL.
> 
> # ls -l
> total 8
> d--------T 2 root root 4096 Jun  4 07:05 s2
> # nsdb-list 
> NSDB: ldap.example.net:389
>  NCE ou=fedfs,dc=example,dc=net has no FSN records
> # nfsref lookup s2
> Segmentation fault
> 
> (gdb) bt
> #0  0x0000000000404eb0 in nfsref_lookup_resolve_fsn (host=0x118d630, fsn_uuid=<optimized out>) at lookup.c:364
> #1  nfsref_lookup_nfs_fedfs (junct_path=<optimized out>) at lookup.c:483
> #2  0x0000000000403cf9 in main (argc=3, argv=0x7fff69dea5e8) at nfsref.c:181

Thanks, pulled this one for testing and further review.

> Signed-off-by: chendt.fnst@cn.fujitsu.com

Just a nit: my git tool chain didn’t like your signed-off because
it had only an email address. Can you use

  Signed-off-by: Ditang Chen <chendt.fnst@cn.fujitsu.com>

for future submissions?

May I fix up this patch with the longer Signed-off-by: ?


> ---
> src/libnsdb/fileserver.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
> index 965f1a1..0899f00 100644
> --- a/src/libnsdb/fileserver.c
> +++ b/src/libnsdb/fileserver.c
> @@ -1527,8 +1527,14 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
> 	ldap_msgfree(response);
> 
> 	if (retval == FEDFS_OK) {
> -		xlog(D_CALL, "%s: returning fsn", __func__);
> -		*fsn = tmp;
> +		if (tmp == NULL) {
> +			xlog(D_CALL, "%s: No FSN entries for FSN UUID %s",
> +				__func__, fsn_uuid);
> +			retval = FEDFS_ERR_NSDB_NOFSN;
> +		} else {
> +			xlog(D_CALL, "%s: returning fsn", __func__);
> +			*fsn = tmp;
> +		}
> 	} else
> 		nsdb_free_fedfs_fsn(tmp);
> 	return retval;
> -- 
> 1.8.4.2
> 

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com

Patch

diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 965f1a1..0899f00 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -1527,8 +1527,14 @@  nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
 	ldap_msgfree(response);
 
 	if (retval == FEDFS_OK) {
-		xlog(D_CALL, "%s: returning fsn", __func__);
-		*fsn = tmp;
+		if (tmp == NULL) {
+			xlog(D_CALL, "%s: No FSN entries for FSN UUID %s",
+				__func__, fsn_uuid);
+			retval = FEDFS_ERR_NSDB_NOFSN;
+		} else {
+			xlog(D_CALL, "%s: returning fsn", __func__);
+			*fsn = tmp;
+		}
 	} else
 		nsdb_free_fedfs_fsn(tmp);
 	return retval;