LP#1098377: protect against even more cstore segfaults
authorGalen Charlton <gmc@esilibrary.com>
Tue, 15 Jan 2013 16:30:41 +0000 (11:30 -0500)
committerBill Erickson <berick@esilibrary.com>
Wed, 16 Jan 2013 20:01:04 +0000 (15:01 -0500)
Following up on the preceding patch, passing null
as the savepoint name to savepoint.release and
savepoint.rollback would also segfault cstore.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/c-apps/oils_sql.c

index 18b0f9c..c67362b 100644 (file)
@@ -969,6 +969,12 @@ int releaseSavepoint( osrfMethodContext* ctx ) {
 
        // Get the savepoint name from the method params
        const char* spName = jsonObjectGetString( jsonObjectGetIndex(ctx->params, spNamePos) );
+
+       if (!spName) {
+               osrfLogWarning(OSRF_LOG_MARK, "savepoint.release called with no name");
+               return -1;
+       }
+
        char *safeSpName = _sanitize_savepoint_name( spName );
 
        dbi_result result = dbi_conn_queryf( writehandle, "RELEASE SAVEPOINT \"%s\";", safeSpName );
@@ -1042,6 +1048,12 @@ int rollbackSavepoint( osrfMethodContext* ctx ) {
 
        // Get the savepoint name from the method params
        const char* spName = jsonObjectGetString( jsonObjectGetIndex(ctx->params, spNamePos) );
+
+       if (!spName) {
+               osrfLogWarning(OSRF_LOG_MARK, "savepoint.rollback called with no name");
+               return -1;
+       }
+
        char *safeSpName = _sanitize_savepoint_name( spName );
 
        dbi_result result = dbi_conn_queryf( writehandle, "ROLLBACK TO SAVEPOINT \"%s\";", safeSpName );