[libgda] More misc. corrections for bugs discovered by CoverityScan
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] More misc. corrections for bugs discovered by CoverityScan
- Date: Wed, 5 Sep 2012 14:11:36 +0000 (UTC)
commit a9d666387b4c84471923e3d98363d27670799373
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Sep 5 16:11:17 2012 +0200
More misc. corrections for bugs discovered by CoverityScan
providers/ldap/gda-ldap-provider.c | 36 +++++++++++++++++----
tools/browser/common/objects-cloud.c | 4 +-
tools/browser/data-manager/data-source-manager.c | 2 +-
tools/gda-sql.c | 8 ++--
4 files changed, 36 insertions(+), 14 deletions(-)
---
diff --git a/providers/ldap/gda-ldap-provider.c b/providers/ldap/gda-ldap-provider.c
index 9d257a5..f9f6047 100644
--- a/providers/ldap/gda-ldap-provider.c
+++ b/providers/ldap/gda-ldap-provider.c
@@ -858,22 +858,44 @@ gda_ldap_provider_statement_execute (GdaServerProvider *provider, GdaConnection
GError *lerror = NULL;
GObject *retval = NULL;
cmde = parse_extra_sql_command (ssql, "DROP", &lerror);
- if ((cmde != NOT_AN_EXTRA_SQL_COMMAND) && !cmde->other_args) {
+ if (cmde != NOT_AN_EXTRA_SQL_COMMAND) {
GdaConnectionEvent *event = NULL;
if (cmde) {
- if (gda_ldap_connection_undeclare_table (GDA_LDAP_CONNECTION (cnc),
- cmde->table_name, &lerror))
- retval = (GObject*) gda_set_new (NULL);
- else {
+ if (cmde->other_args) {
+ g_set_error (&error, GDA_SQL_PARSER_ERROR,
+ GDA_SQL_PARSER_SYNTAX_ERROR,
+ "%s",
+ _("Too many arguments"));
event = gda_connection_point_available_event (cnc,
GDA_CONNECTION_EVENT_ERROR);
- gda_connection_event_set_description (event, lerror && lerror->message ?
- lerror->message : _("No detail"));
+ gda_connection_event_set_description (event,
+ lerror->message);
gda_connection_add_event (cnc, event);
g_propagate_error (error, lerror);
}
+ else {
+ if (gda_ldap_connection_undeclare_table (GDA_LDAP_CONNECTION (cnc),
+ cmde->table_name, &lerror))
+ retval = (GObject*) gda_set_new (NULL);
+ else {
+ event = gda_connection_point_available_event (cnc,
+ GDA_CONNECTION_EVENT_ERROR);
+ gda_connection_event_set_description (event, lerror && lerror->message ?
+ lerror->message : _("No detail"));
+ gda_connection_add_event (cnc, event);
+ g_propagate_error (error, lerror);
+ }
+ }
extra_sql_command_free (cmde);
}
+ else {
+ event = gda_connection_point_available_event (cnc,
+ GDA_CONNECTION_EVENT_ERROR);
+ gda_connection_event_set_description (event, lerror && lerror->message ?
+ lerror->message : _("No detail"));
+ gda_connection_add_event (cnc, event);
+ g_propagate_error (error, lerror);
+ }
gda_connection_internal_statement_executed (cnc, stmt, params, event);
g_free (sql);
return retval;
diff --git a/tools/browser/common/objects-cloud.c b/tools/browser/common/objects-cloud.c
index 5b2b2fa..0ca09e2 100644
--- a/tools/browser/common/objects-cloud.c
+++ b/tools/browser/common/objects-cloud.c
@@ -236,8 +236,8 @@ update_display (ObjectsCloud *cloud)
g_slist_free (dbo_list);
out:
- if (default_sd)
- schemas = g_slist_prepend (schemas, default_sd);
+ /* default_sd can't be NULL here */
+ schemas = g_slist_prepend (schemas, default_sd);
/* get rid of the SchemaData structures */
for (list = schemas; list; list = list->next) {
diff --git a/tools/browser/data-manager/data-source-manager.c b/tools/browser/data-manager/data-source-manager.c
index ce6114d..eecf0e4 100644
--- a/tools/browser/data-manager/data-source-manager.c
+++ b/tools/browser/data-manager/data-source-manager.c
@@ -518,7 +518,7 @@ data_source_manager_get_sources_array (DataSourceManager *mgr, G_GNUC_UNUSED GEr
import = data_source_get_import (source);
if (!import) {
if (! array) {
- array = g_array_new (FALSE, FALSE, sizeof (GArray*));
+ array = g_array_new (FALSE, FALSE, sizeof (gpointer));
GArray *subarray = g_array_new (FALSE, FALSE, sizeof (DataSource*));
g_array_append_val (array, subarray);
g_array_append_val (subarray, source);
diff --git a/tools/gda-sql.c b/tools/gda-sql.c
index aefb428..6df4d8f 100644
--- a/tools/gda-sql.c
+++ b/tools/gda-sql.c
@@ -1376,21 +1376,21 @@ compute_prompt (SqlConsole *console, GString *string, gboolean in_command, Outpu
* Check that the @arg string can safely be passed to a shell
* to be executed, i.e. it does not contain dangerous things like "rm -rf *"
*/
+// coverity[ +tainted_string_sanitize_content : arg-0 ]
static gboolean
check_shell_argument (const gchar *arg)
{
const gchar *ptr;
g_assert (arg);
- g_print ("[%s]\n", arg);
/* check for starting spaces */
- for (ptr = arg; * ptr && (*ptr == ' '); ptr++);
+ for (ptr = arg; *ptr == ' '; ptr++);
if (!*ptr)
return FALSE; /* only spaces is not allowed */
/* check for the rest */
- for (; * ptr; ptr++) {
- if (! isalnum (*ptr) && (*ptr != G_DIR_SEPARATOR))
+ for (; *ptr; ptr++) {
+ if (! g_ascii_isalnum (*ptr) && (*ptr != G_DIR_SEPARATOR))
return FALSE;
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]