]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add some err checking to sqlite case for nonce checking
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 22 Jul 2009 20:37:20 +0000 (20:37 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 22 Jul 2009 20:37:20 +0000 (20:37 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14322 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_db.c

index 306f54e7ea00d5f1b77f89c83d21f541259c24e3..67baaae2e1dcebb99f825b0b664f3906a50a852f 100644 (file)
@@ -4016,11 +4016,16 @@ char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex
 
                while (running < 5000) {
                        int result = switch_core_db_step(stmt);
+                       const unsigned char *txt;
 
                        if (result == SWITCH_CORE_DB_ROW) {
-                               if ((colcount = switch_core_db_column_count(stmt))) {
-                                       switch_copy_string(resbuf, (char *) switch_core_db_column_text(stmt, 0), len);
-                                       ret = resbuf;
+                               if ((colcount = switch_core_db_column_count(stmt)) > 0) {
+                                       if ((txt = switch_core_db_column_text(stmt, 0))) {
+                                               switch_copy_string(resbuf, (char *) txt, len);
+                                               ret = resbuf;
+                                       } else {
+                                               goto fail;
+                                       }
                                }
                                break;
                        } else if (result == SWITCH_CORE_DB_BUSY) {
index 863425139ed267267815d3919138600da68cd356..e675569aa5f56a17b9b4c39876402b288fc1640e 100644 (file)
@@ -57,7 +57,14 @@ SWITCH_DECLARE(int) switch_core_db_close(switch_core_db_t *db)
 
 SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol)
 {
-       return sqlite3_column_text(stmt, iCol);
+    const unsigned char *txt = sqlite3_column_text(stmt, iCol);
+
+    if (txt && !strcasecmp((char *)txt, "(null)")) {
+        txt = NULL;
+    }
+
+    return txt;
+
 }
 
 SWITCH_DECLARE(const char *) switch_core_db_column_name(switch_core_db_stmt_t *stmt, int N)