[fedfs-utils] [PATCH 09/11] libnsdb: nsdb_read_nsdbname() should tolerate uninit'd securityFile
Chuck Lever
chuck.lever at oracle.com
Thu Jan 24 10:35:49 PST 2013
nsdb_read_nsdbname() should not cause a segfault if the securityFile
field has not been initialized.
Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---
src/libnsdb/nsdb.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index 891c35b..3bfb50e 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -603,10 +603,16 @@ nsdb_read_nsdbname(sqlite3 *db, nsdb_t host)
switch (sqlite3_step(stmt)) {
case SQLITE_ROW:
+ retval = FEDFS_ERR_SVRFAULT;
xlog(D_GENERAL, "Found row for '%s:%u'", domainname, port);
- certfile = strdup((const char *)sqlite3_column_text(stmt, 1));
- if (certfile == NULL) {
- retval = FEDFS_ERR_SVRFAULT;
+ certfile = (char *)sqlite3_column_text(stmt, 1);
+ if (certfile != NULL) {
+ certfile = strdup(certfile);
+ if (certfile == NULL)
+ break;
+ } else {
+ xlog(D_GENERAL, "%s: Uninitialized securityFile field "
+ "for NSDB %s:%u", __func__, domainname, port);
break;
}
def_binddn = (char *)sqlite3_column_text(stmt, 2);
@@ -614,7 +620,6 @@ nsdb_read_nsdbname(sqlite3 *db, nsdb_t host)
def_binddn = strdup(def_binddn);
if (def_binddn == NULL) {
free(certfile);
- retval = FEDFS_ERR_SVRFAULT;
break;
}
}
@@ -624,7 +629,6 @@ nsdb_read_nsdbname(sqlite3 *db, nsdb_t host)
if (def_nce == NULL) {
free(def_binddn);
free(certfile);
- retval = FEDFS_ERR_SVRFAULT;
break;
}
}
More information about the fedfs-utils-devel
mailing list