@@ -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);
@@ -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",
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@oracle.com> --- src/libnsdb/fileserver.c | 9 ++++++--- src/nsdbc/nsdb-list.c | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-)