From patchwork Thu Jan 2 20:27:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 306263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B88112C0091 for ; Fri, 3 Jan 2014 07:27:35 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s02KRURT010681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Jan 2014 20:27:31 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s02KRURu018146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Jan 2014 20:27:30 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Vyora-0006hF-Ec; Thu, 02 Jan 2014 12:27:30 -0800 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1VyorD-0006fc-K2 for fedfs-utils-devel@oss.oracle.com; Thu, 02 Jan 2014 12:27:07 -0800 Received: from userp1030.oracle.com (userp1030.oracle.com [156.151.31.80]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s02KR6Lw011788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Jan 2014 20:27:07 GMT Received: from mail-yh0-f50.google.com (mail-yh0-f50.google.com [209.85.213.50]) by userp1030.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id s02KR5IH011174 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 2 Jan 2014 20:27:06 GMT Received: by mail-yh0-f50.google.com with SMTP id b6so2954440yha.23 for ; Thu, 02 Jan 2014 12:27:05 -0800 (PST) X-Received: by 10.236.152.233 with SMTP id d69mr50634588yhk.11.1388694425311; Thu, 02 Jan 2014 12:27:05 -0800 (PST) Received: from seurat.1015granger.net ([2604:8800:100:81fc:20c:29ff:fe44:ec31]) by mx.google.com with ESMTPSA id z7sm14724463yha.14.2014.01.02.12.27.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jan 2014 12:27:04 -0800 (PST) To: fedfs-utils-devel@oss.oracle.com From: Chuck Lever Date: Thu, 02 Jan 2014 15:27:03 -0500 Message-ID: <20140102202703.2964.27008.stgit@seurat.1015granger.net> In-Reply-To: <20140102202359.2964.95143.stgit@seurat.1015granger.net> References: <20140102202359.2964.95143.stgit@seurat.1015granger.net> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=209.85.213.50 ct-class=R5 ct-vol1=-98 ct-vol2=7 ct-vol3=7 ct-risk=56 ct-spam1=92 ct-spam2=7 ct-bulk=2 rcpts=1 size=7278 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=E5H0+8tl c=1 sm=1 tr=0 a=N8YdRB4kyzZ/wH9ves9p+g==:117 a=dzsqy3y4QnMA:10 a=1AMn-GoYelsA:10 a=dPGociXpb70A:10 a=IkcTkHD0fZMA:10 a=xqWC_Br6kY4A:10 a=yPCof4ZbAAAA:8 a=Lb1rMZzfAAAA:8 a=1XWaLZrsAAAA:8 a=-JGiWS_08xkA:10 a=VCiT0BYPmd4_U xTeltsA:9 a=QEXdDO2ut3YA:10 a=7DSvI1NPTFQA:10 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090206.52C5CB9A.00D3, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Subject: [fedfs-utils] [PATCH 01/17] libnsdb: Check "host" parameter 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: acsinet22.oracle.com [141.146.126.238] libnsdb is intended to provide a public API, and as such, it is careful to check all incoming parameters. For some reason, though, it doesn't verify that host != NULL. Add that check. Signed-off-by: Chuck Lever --- src/libnsdb/administrator.c | 55 +++++++++++++++++++++++++++++++++++++++++++ src/libnsdb/fileserver.c | 35 +++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/src/libnsdb/administrator.c b/src/libnsdb/administrator.c index 2e4aa0d..7fc5f71 100644 --- a/src/libnsdb/administrator.c +++ b/src/libnsdb/administrator.c @@ -276,6 +276,11 @@ FedFsStatus nsdb_create_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid, const unsigned int ttl, unsigned int *ldap_err) { + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -549,6 +554,11 @@ nsdb_delete_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid, FedFsStatus retval; char *dn; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -891,6 +901,11 @@ nsdb_create_fsls_s(nsdb_t host, const char *nce, struct fedfs_fsl *fsls, struct fedfs_fsl *fsl, *progress; FedFsStatus retval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(D_GENERAL, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1072,6 +1087,11 @@ nsdb_delete_fsl_s(nsdb_t host, const char *nce, const char *fsl_uuid, FedFsStatus retval; char *dn; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1198,6 +1218,11 @@ nsdb_update_fsl_s(nsdb_t host, const char *nce, const char *fsl_uuid, FedFsStatus retval; char *dn; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1385,6 +1410,11 @@ nsdb_create_simple_nce_s(nsdb_t host, const char *parent, FedFsStatus retval; char *nce; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1475,6 +1505,11 @@ nsdb_update_nci_s(nsdb_t host, const char *nce, unsigned int *ldap_err) FedFsStatus retval; char *context; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1590,6 +1625,11 @@ nsdb_remove_nci_s(nsdb_t host, const char *nce, unsigned int *ldap_err) FedFsStatus retval; char *context; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1737,6 +1777,11 @@ nsdb_delete_nsdb_s(nsdb_t host, const char *nce, unsigned int *ldap_err) { FedFsStatus retval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1780,6 +1825,11 @@ nsdb_attr_add_s(nsdb_t host, const char *dn, const char *attr, { struct berval bval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1828,6 +1878,11 @@ nsdb_attr_delete_s(nsdb_t host, const char *dn, const char *attr, { struct berval bval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c index fdd0878..9484591 100644 --- a/src/libnsdb/fileserver.c +++ b/src/libnsdb/fileserver.c @@ -606,6 +606,11 @@ nsdb_get_ncedn_s(nsdb_t host, const char *naming_context, char **dn, { FedFsStatus retval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -726,6 +731,11 @@ nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts, char **tmp; int rc; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1285,6 +1295,11 @@ nsdb_resolve_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid, FedFsStatus retval; int i, j; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1596,6 +1611,11 @@ nsdb_get_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid, FedFsStatus retval; int i, j; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1850,6 +1870,11 @@ nsdb_list_s(nsdb_t host, const char *nce, char ***fsns, unsigned int *ldap_err) FedFsStatus retval; int i, j; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -1960,6 +1985,11 @@ nsdb_ping_nsdb_s(nsdb_t host, unsigned int *ldap_err) FedFsStatus retval; char **contexts = NULL; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL; @@ -2082,6 +2112,11 @@ nsdb_find_naming_context_s(nsdb_t host, const char *entry, char **context, char **contexts = NULL; FedFsStatus retval; + if (host == NULL) { + xlog(L_ERROR, "%s: Invalid host parameter", __func__); + return FEDFS_ERR_INVAL; + } + if (host->fn_ldap == NULL) { xlog(L_ERROR, "%s: NSDB not open", __func__); return FEDFS_ERR_INVAL;