[OpenSIPS-Devel] [opensips] Use DB_STR instead of DB_STRING for string value (and as default value) (#618)

Minh PHAN notifications at github.com
Wed Aug 26 14:31:43 CEST 2015


There is currently a bug with dialog persistency using postgres database. If OpenSIPS is restarted, all dialogs variables are lost (not read from database at start-up).
The bug comes from this block of code (line 1616 in dlg_db_handler.c)
                    if (!VAL_NULL(values+18))
                        read_dialog_vars( VAL_STR(values+18).s,
                            VAL_STR(values+18).len, known_dlg);
As the DB type for string in db_postgres module is DB_STRING (NULL terminated string),  VAL_STR(values+18).len is always 0 (or undefined), hence dialog variables are never read from database.

This bug could be fix by replacing  VAL_STR(values+18).len by strlen(VAL_STR(values+18)). However, I think it's better to change DB type for string to DB_STR to avoid this kind of bug in the future.

You can view, comment on, or merge this pull request online at:

  https://github.com/OpenSIPS/opensips/pull/618

-- Commit Summary --

  * change default database type for postgres to DB_STR instead of DB_STRING so that code in dialog module that use VAL_STR().len will work. This should be safe as postgres module always put the '\0' at the end of string value so STR value can always be accessed as by STRING type

-- File Changes --

    M modules/db_postgres/res.c (6)

-- Patch Links --

https://github.com/OpenSIPS/opensips/pull/618.patch
https://github.com/OpenSIPS/opensips/pull/618.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/618
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20150826/362a9ac6/attachment.htm>


More information about the Devel mailing list