<p>Abhay Gupta has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13851">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_odbc.h: Added StrLen_or_IndPtr for use in SQLBindParameter<br><br>While using some Databases like Apache Ignite it was observed that<br>in case the last parameter StrLen_or_IndPtr to SQLBindParemeter is passed<br>as NULL then on SQLExecute we do not get records and the documentation<br>shows that StrLen_or_IndPtr should pass SQL_NTS to tell that the parameter<br>value is a null-terminated string<br><br>ASTERISK-28763<br><br>Change-Id: Ia8c3fda14b9008e22fb4893204911259f600b32e<br>---<br>M apps/app_voicemail.c<br>M cdr/cdr_odbc.c<br>M include/asterisk/res_odbc.h<br>M res/res_config_odbc.c<br>4 files changed, 56 insertions(+), 42 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/51/13851/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 67204f0..0806e32 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -3871,9 +3871,11 @@</span><br><span>           SQLFreeHandle(SQL_HANDLE_STMT, stmt);</span><br><span>                return NULL;</span><br><span>         }</span><br><span style="color: hsl(0, 100%, 40%);">-       for (i = 0; i < gps->argc; i++)</span><br><span style="color: hsl(0, 100%, 40%);">-           SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(gps->argv[i]), 0, gps->argv[i], 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Passing SQL_NTS to define that parameter value is NULL terminated while using SQL_CHAR */</span><br><span style="color: hsl(120, 100%, 40%);">+  obj->len = SQL_NTS;</span><br><span style="color: hsl(120, 100%, 40%);">+        for (i = 0; i < gps->argc; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(gps->argv[i]), 0, gps->argv[i], 0,&obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span>    return stmt;</span><br><span> }</span><br><span> </span><br><span>@@ -4372,21 +4374,22 @@</span><br><span>              ast_log(AST_LOG_WARNING, "SQL Alloc Handle failed!\n");</span><br><span>            return NULL;</span><br><span>         }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *) data->dir, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-      SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *) data->msgnums, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Passing SQL_NTS to define that parameter value is NULL terminated while using SQL_CHAR */</span><br><span style="color: hsl(120, 100%, 40%);">+  obj->len = SQL_NTS;</span><br><span style="color: hsl(120, 100%, 40%);">+        SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *) data->dir, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+        SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *) data->msgnums, 0, &obj->len);</span><br><span>       SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *) data->data, data->datalen, &data->indlen);</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *) data->context, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-      SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->macrocontext), 0, (void *) data->macrocontext, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *) data->callerid, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *) data->origtime, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *) data->duration, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *) data->mailboxuser, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-      SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *) data->mailboxcontext, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *) data->flag, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-   SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+     SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *) data->context, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+        SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->macrocontext), 0, (void *) data->macrocontext, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *) data->callerid, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *) data->origtime, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *) data->duration, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *) data->mailboxuser, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+        SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *) data->mailboxcontext, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *) data->flag, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+     SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 0, &obj->len);</span><br><span>        if (!ast_strlen_zero(data->category)) {</span><br><span style="color: hsl(0, 100%, 40%);">-              SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+         SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, &obj->len);</span><br><span>    }</span><br><span>    res = ast_odbc_execute_sql(obj, stmt, data->sql);</span><br><span>         if (!SQL_SUCCEEDED(res)) {</span><br><span>diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c</span><br><span>index e7dd9c0..d57354e 100644</span><br><span>--- a/cdr/cdr_odbc.c</span><br><span>+++ b/cdr/cdr_odbc.c</span><br><span>@@ -104,15 +104,16 @@</span><br><span>              SQLFreeHandle(SQL_HANDLE_STMT, stmt);</span><br><span>                return NULL;</span><br><span>         }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dcontext), 0, cdr->dcontext, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->channel), 0, cdr->channel, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dstchannel), 0, cdr->dstchannel, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-   SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastapp), 0, cdr->lastapp, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastdata), 0, cdr->lastdata, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Passing SQL_NTS to define that parameter value is NULL terminated while using SQL_CHAR */</span><br><span style="color: hsl(120, 100%, 40%);">+  obj->len = SQL_NTS;</span><br><span style="color: hsl(120, 100%, 40%);">+        SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+   SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+   SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dcontext), 0, cdr->dcontext, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->channel), 0, cdr->channel, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+   SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dstchannel), 0, cdr->dstchannel, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+     SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastapp), 0, cdr->lastapp, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+   SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastdata), 0, cdr->lastdata, 0, &obj->len);</span><br><span> </span><br><span>    if (ast_test_flag(&config, CONFIG_HRTIME)) {</span><br><span>             double hrbillsec = 0.0;</span><br><span>@@ -123,34 +124,34 @@</span><br><span>              }</span><br><span>            hrduration = (double) ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-            SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+          SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrduration, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+              SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_FLOAT, 0, 0, &hrbillsec, 0, &obj->len);</span><br><span>     } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-             SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+           SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, &obj->len);</span><br><span>      }</span><br><span> </span><br><span>        if (ast_test_flag(&config, CONFIG_DISPOSITIONSTRING)) {</span><br><span>          char *disposition;</span><br><span>           disposition = ast_strdupa(ast_cdr_disp2str(cdr->disposition));</span><br><span style="color: hsl(0, 100%, 40%);">-               SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(disposition) + 1, 0, disposition, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+          SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(disposition) + 1, 0, disposition, 0, &obj->len);</span><br><span>     } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, &obj->len);</span><br><span>  }</span><br><span style="color: hsl(0, 100%, 40%);">-       SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->accountcode), 0, cdr->accountcode, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+      SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->accountcode), 0, cdr->accountcode, 0, &obj->len);</span><br><span> </span><br><span>     i = 14;</span><br><span>      if (ast_test_flag(&config, CONFIG_LOGUNIQUEID)) {</span><br><span style="color: hsl(0, 100%, 40%);">-           SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->uniqueid), 0, cdr->uniqueid, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-              SQLBindParameter(stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->userfield), 0, cdr->userfield, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+          SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->uniqueid), 0, cdr->uniqueid, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+                SQLBindParameter(stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->userfield), 0, cdr->userfield, 0, &obj->len);</span><br><span>             i = 16;</span><br><span>      }</span><br><span> </span><br><span>        if (ast_test_flag(&config, CONFIG_NEWCDRCOLUMNS)) {</span><br><span style="color: hsl(0, 100%, 40%);">-         SQLBindParameter(stmt, i, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->peeraccount), 0, cdr->peeraccount, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-         SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->linkedid), 0, cdr->linkedid, 0, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-           SQLBindParameter(stmt, i + 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->sequence, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, i, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->peeraccount), 0, cdr->peeraccount, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+           SQLBindParameter(stmt, i + 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->linkedid), 0, cdr->linkedid, 0, &obj->len);</span><br><span style="color: hsl(120, 100%, 40%);">+             SQLBindParameter(stmt, i + 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->sequence, 0, &obj->len);</span><br><span>  }</span><br><span> </span><br><span>        ODBC_res = ast_odbc_execute_sql(obj, stmt, sqlcmd);</span><br><span>diff --git a/include/asterisk/res_odbc.h b/include/asterisk/res_odbc.h</span><br><span>index 9a38915..f3a7e30 100644</span><br><span>--- a/include/asterisk/res_odbc.h</span><br><span>+++ b/include/asterisk/res_odbc.h</span><br><span>@@ -43,8 +43,14 @@</span><br><span> };</span><br><span> </span><br><span> /*! \brief ODBC container */</span><br><span style="color: hsl(120, 100%, 40%);">+/* While using some Databases like Apache Ignite it was observed that</span><br><span style="color: hsl(120, 100%, 40%);">+* in case the last parameter StrLen_or_IndPtr is passed as NULL then </span><br><span style="color: hsl(120, 100%, 40%);">+* on SQLExecute we do not get records and the documentation shows that</span><br><span style="color: hsl(120, 100%, 40%);">+* StrLen_or_IndPtr should pass SQL_NTS. The parameter value is a </span><br><span style="color: hsl(120, 100%, 40%);">+* null-terminated string */</span><br><span> struct odbc_obj {</span><br><span>       SQLHDBC  con;                   /*!< ODBC Connection Handle */</span><br><span style="color: hsl(120, 100%, 40%);">+     SQLLEN len;                     /*!< StrLen_or_IndPtr */</span><br><span>  struct odbc_class *parent;      /*!< Information about the connection is protected */</span><br><span> #ifdef DEBUG_THREADS</span><br><span>     char file[80];</span><br><span>diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c</span><br><span>index 45bb214..937fe7d 100644</span><br><span>--- a/res/res_config_odbc.c</span><br><span>+++ b/res/res_config_odbc.c</span><br><span>@@ -111,6 +111,8 @@</span><br><span>                ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");</span><br><span>                return NULL;</span><br><span>         }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Passing SQL_NTS to define that parameter value is NULL terminated while using SQL_CHAR */</span><br><span style="color: hsl(120, 100%, 40%);">+  obj->len = SQL_NTS;</span><br><span> </span><br><span>   ast_debug(1, "Skip: %llu; SQL: %s\n", cps->skip, cps->sql);</span><br><span> </span><br><span>@@ -137,7 +139,7 @@</span><br><span>                        ast_string_field_set(cps, encoding[x], encodebuf);</span><br><span>                   newval = cps->encoding[x];</span><br><span>                }</span><br><span style="color: hsl(0, 100%, 40%);">-               SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, &obj->len);</span><br><span>  }</span><br><span> </span><br><span>        if (!ast_strlen_zero(cps->extra)) {</span><br><span>@@ -148,7 +150,7 @@</span><br><span>                         ast_string_field_set(cps, encoding[x], encodebuf);</span><br><span>                   newval = cps->encoding[x];</span><br><span>                }</span><br><span style="color: hsl(0, 100%, 40%);">-               SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+               SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, &obj->len);</span><br><span>  }</span><br><span> </span><br><span>        return stmt;</span><br><span>@@ -618,13 +620,15 @@</span><br><span>                 ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");</span><br><span>                return NULL;</span><br><span>         }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Passing SQL_NTS to define that parameter value is NULL terminated while using SQL_CHAR */</span><br><span style="color: hsl(120, 100%, 40%);">+  obj->len = SQL_NTS;</span><br><span> </span><br><span>   ast_str_set(&sql, 0, "UPDATE %s SET ", ups->table);</span><br><span> </span><br><span>     for (field = ups->update_fields; field; field = field->next) {</span><br><span>                 if (ast_odbc_find_column(ups->tableptr, field->name)) {</span><br><span>                        ast_str_append(&sql, 0, "%s%s=? ", first ? "" : ", ", field->name);</span><br><span style="color: hsl(0, 100%, 40%);">-                        SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(field->name), 0, (void *)field->value, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+                      SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(field->name), 0, (void *)field->value, 0, &obj->len);</span><br><span>                         first = 0;</span><br><span>           } else {</span><br><span>                     ast_log(LOG_NOTICE, "Not updating column '%s' in '%s@%s' because that column does not exist!\n", field->name, ups->table, ups->database);</span><br><span>@@ -641,7 +645,7 @@</span><br><span>                   return NULL;</span><br><span>                 }</span><br><span>            ast_str_append(&sql, 0, "%s %s=?", first ? "" : " AND", field->name);</span><br><span style="color: hsl(0, 100%, 40%);">-              SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(field->value), 0, (void *)field->value, 0, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+             SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(field->value), 0, (void *)field->value, 0, &obj->len);</span><br><span>                first = 0;</span><br><span>   }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13851">change 13851</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13851"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ia8c3fda14b9008e22fb4893204911259f600b32e </div>
<div style="display:none"> Gerrit-Change-Number: 13851 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Abhay Gupta <abhay@avissol.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>