Detect and report certain malformations in the ORDER BY clause
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 2 May 2009 19:54:59 +0000 (19:54 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 2 May 2009 19:54:59 +0000 (19:54 +0000)
(which would otherwise cause segfaults).

git-svn-id: svn://svn.open-ils.org/ILS/trunk@13037 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_cstore.c

index 13fde5b..dfb9068 100644 (file)
@@ -3634,6 +3634,28 @@ char* SELECT (
                                                                }
                                                        }
 
+                                               } else if ( JSON_NULL == onode->type || JSON_ARRAY == onode->type ) {
+                                                       osrfLogError( OSRF_LOG_MARK,
+                                                               "%s: Expected JSON_STRING in ORDER BY clause; found %s",
+                                                               MODULENAME, json_type( onode->type ) );
+                                                       if( ctx )
+                                                               osrfAppSessionStatus(
+                                                                       ctx->session,
+                                                                       OSRF_STATUS_INTERNALSERVERERROR,
+                                                                       "osrfMethodException",
+                                                                       ctx->request,
+                                                                       "Malformed ORDER BY clause -- see error log for more details"
+                                                               );
+                                                       jsonIteratorFree( order_itr );
+                                                       jsonIteratorFree( class_itr );
+                                                       free(core_class);
+                                                       buffer_free(having_buf);
+                                                       buffer_free(group_buf);
+                                                       buffer_free(order_buf);
+                                                       buffer_free(sql_buf);
+                                                       if (defaultselhash) jsonObjectFree(defaultselhash);
+                                                       return NULL;
+
                                                } else {
                                                        string = strdup(order_itr->key);
                                                        const char* dir = jsonObjectGetString(onode);