From patchwork Thu Nov 3 15:28:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 123456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "acsinet15.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 036B2B6F7E for ; Fri, 4 Nov 2011 02:28:38 +1100 (EST) Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pA3FSYAW005158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Nov 2011 15:28:35 GMT Received: from oss.oracle.com (oss.oracle.com [141.146.12.120]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pA3FSXYN007306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Nov 2011 15:28:34 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RLzDQ-0001jL-Rr; Thu, 03 Nov 2011 08:28:28 -0700 Received: from acsinet13.oracle.com ([141.146.126.235]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RLzDP-0001jE-4g for fedfs-utils-devel@oss.oracle.com; Thu, 03 Nov 2011 08:28:27 -0700 Received: from mail-qw0-f43.google.com (mail-qw0-f43.google.com [209.85.216.43]) by acsinet13.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pA3FS6DI015462 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Thu, 3 Nov 2011 15:28:26 GMT Received: by mail-qw0-f43.google.com with SMTP id g1so1528086qab.2 for ; Thu, 03 Nov 2011 08:28:26 -0700 (PDT) Received: by 10.224.206.132 with SMTP id fu4mr4972760qab.20.1320334106421; Thu, 03 Nov 2011 08:28:26 -0700 (PDT) Received: from degas.1015granger.net ([99.26.161.222]) by mx.google.com with ESMTPS id ed2sm6299217qab.15.2011.11.03.08.28.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Nov 2011 08:28:25 -0700 (PDT) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Thu, 03 Nov 2011 11:28:23 -0400 Message-ID: <20111103152823.2445.46038.stgit@degas.1015granger.net> In-Reply-To: <20111103152051.2445.69747.stgit@degas.1015granger.net> References: <20111103152051.2445.69747.stgit@degas.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=ISPs ip=209.85.216.43 ct-class=R6 ct-vol1=0 ct-vol2=0 ct-vol3=0 ct-risk=68 ct-spam1=0 ct-spam2=0 ct-bulk=0 rcpts=1 size=1896 Subject: [fedfs-utils] [PATCH 2/7] libnsdb: nsdb_list_s() returns FEDFS_OK without updating "fsns" X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-CT-RefId: str=0001.0A090207.4EB2B324.0065:SCFSTAT3865452, ss=1, re=-4.000, fgs=0 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 --- 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",