[fedfs-utils] [PATCH 2/7] libnsdb: nsdb_list_s() returns FEDFS_OK without updating "fsns"
Chuck Lever
chuck.lever at oracle.com
Thu Nov 3 08:28:23 PDT 2011
Trying the nsdb-list command against an empty NSDB causes a
segmentation fault. This is because nsdb_list_s() found no FSN
records. It did not alter the "fsns" output argument, but returned
FEDFS_OK anyway.
nsdb_list_s() needs to return an appropriate error code if it does not
plant anything in the "fsns" output argument.
To address this, copy the logic from the tail of nsdb_resolve_fsn_s().
And, fix the nsdb-list command to recognize FEDFS_ERR_NSDB_NOFSN and
report an appropriate error message.
Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---
src/libnsdb/fileserver.c | 9 ++++++---
src/nsdbc/nsdb-list.c | 4 ++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 22d192e..a7631e8 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -1217,10 +1217,13 @@ nsdb_list_s(nsdb_t host, const char *nce, char ***fsns, unsigned int *ldap_err)
if (j == 0)
goto out;
- for (j = 0; nce_list[j] != NULL; j++)
- nsdb_list_find_entries_s(host->fn_ldap, nce_list[j],
+ for (j = 0; nce_list[j] != NULL; j++) {
+ retval = nsdb_list_find_entries_s(host->fn_ldap,
+ nce_list[j],
fsns, ldap_err);
- retval = FEDFS_OK;
+ if (retval == FEDFS_OK)
+ break;
+ }
out:
nsdb_free_string_array(nce_list);
diff --git a/src/nsdbc/nsdb-list.c b/src/nsdbc/nsdb-list.c
index 6787076..1ac04b0 100644
--- a/src/nsdbc/nsdb-list.c
+++ b/src/nsdbc/nsdb-list.c
@@ -256,6 +256,10 @@ main(int argc, char **argv)
nsdb_list_resolve_and_display_fsn(host, nce, fsns[i]);
nsdb_free_string_array(fsns);
break;
+ case FEDFS_ERR_NSDB_NOFSN:
+ fprintf(stderr, "NSDB %s:%u has no FSN records\n",
+ nsdbname, nsdbport);
+ break;
case FEDFS_ERR_NSDB_NONCE:
if (nce == NULL)
fprintf(stderr, "NSDB %s:%u has no NCE\n",
More information about the fedfs-utils-devel
mailing list