Verify savepoint name is non-null
authorBill Erickson <berick@esilibrary.com>
Tue, 15 Jan 2013 15:58:16 +0000 (10:58 -0500)
committerBill Erickson <berick@esilibrary.com>
Wed, 16 Jan 2013 20:01:01 +0000 (15:01 -0500)
Before we attempt to mangle the name, let's ensure that it's non-null.
Otherwise, segfaults ensue.

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

index d27c272..18b0f9c 100644 (file)
@@ -890,6 +890,12 @@ int setSavepoint( 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.set called with no name");
+               return -1;
+       }
+
        char *safeSpName = _sanitize_savepoint_name( spName );
 
        dbi_result result = dbi_conn_queryf( writehandle, "SAVEPOINT \"%s\";", safeSpName );