[OpenSIPS-Devel] [ opensips-Bugs-2791758 ] xcap_client fails to store the xcap document in the database
SourceForge.net
noreply at sourceforge.net
Thu May 21 13:33:06 CEST 2009
Bugs item #2791758, was opened at 2009-05-14 18:02
Message generated for change (Settings changed) made by anca_vamanu
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=2791758&group_id=232389
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: 1.5.x
>Status: Closed
>Resolution: Fixed
Priority: 9
Private: No
Submitted By: genady (genabel)
Assigned to: Anca Vamanu (anca_vamanu)
Summary: xcap_client fails to store the xcap document in the database
Initial Comment:
the xcap document fetched from the non integrated xcap server cannot be saved in the mysql database. The error messages are:
ERROR:db_mysql:db_mysql_val2str: destination buffer too short
ERROR:core:db_print_values: Error while converting value to string
I analysed the source code of xcap_functions.c xcapGetNewDoc and found out that instead of str structure, char* and string_val should be used.
This is due to fact, that in db_mysql/val.c db_mysql_val2str something goes wrong here:
if (*_len < (VAL_STR(_v).len * 2 + 3)) {
LM_ERR("destination buffer too short\n");
return -6;
...
This line caused bug:
query_vals[n_query_cols].val.str_val = user;
This solves the problem:
query_vals[n_query_cols].val.string_val = user.s;
This is also valid for the domain parameter passed to , here is the snippet of the working code, storing the data in the database:
/* insert in xcap table*/
query_cols[n_query_cols] = &str_username_col;
query_vals[n_query_cols].type = DB_STR;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.string_val = user.s;
n_query_cols++;
query_cols[n_query_cols] = &str_domain_col;
query_vals[n_query_cols].type = DB_STR;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.string_val = domain.s;
n_query_cols++;
query_cols[n_query_cols] = &str_doc_col;
query_vals[n_query_cols].type = DB_BLOB;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.string_val= doc;
n_query_cols++;
query_cols[n_query_cols] = &str_doc_type_col;
query_vals[n_query_cols].type = DB_INT;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.int_val= req.doc_sel.doc_type;
n_query_cols++;
query_cols[n_query_cols] = &str_etag_col;
query_vals[n_query_cols].type = DB_STRING;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.string_val= etag;
n_query_cols++;
query_cols[n_query_cols] = &str_source_col;
query_vals[n_query_cols].type = DB_INT;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.int_val= XCAP_CL_MOD;
n_query_cols++;
query_cols[n_query_cols] = &str_doc_uri_col;
query_vals[n_query_cols].type = DB_STRING;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.string_val= path;
n_query_cols++;
query_cols[n_query_cols] = &str_port_col;
query_vals[n_query_cols].type = DB_INT;
query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.int_val= req.port;
n_query_cols++;
The 100% solution is to fix the db_mysql/val.c db_mysql_val2str for str type.
Regards, Genady
----------------------------------------------------------------------
>Comment By: Anca Vamanu (anca_vamanu)
Date: 2009-05-21 14:33
Message:
Hi Genady,
I have fixed the code yesterday.
The problem was indeed with the blob type, the module used a str structure
for fetching and storing the results.
Thank you for debugging this.
regards,
Anca
----------------------------------------------------------------------
Comment By: genady (genabel)
Date: 2009-05-20 14:59
Message:
Anca, after a while I discovered that the existing branch code for
query_cols and query_vals is valid except DB_BLOB. See my previous comment
to this bug entry.
Best regards,
Genady
----------------------------------------------------------------------
Comment By: Anca Vamanu (anca_vamanu)
Date: 2009-05-19 13:41
Message:
Hi Genady,
Thanks for debugging the error and finding the solution. I will test
myself and apply the changes to svn.
regards,
Anca
----------------------------------------------------------------------
Comment By: genady (genabel)
Date: 2009-05-19 12:12
Message:
sorry, the BLOB handling should be done like this, since the BLOB value
must be str instead of char*:
query_cols[n_query_cols] = &str_doc_col;
query_vals[n_query_cols].type = DB_BLOB;
query_vals[n_query_cols].nul = 0;
/* change start*/
str str_doc={doc, strlen(doc)};
query_vals[n_query_cols].val.str_val= str_doc;
/* change end */
n_query_cols++;
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=2791758&group_id=232389
More information about the Devel
mailing list