Skip to content

Loading a db_text file with one unterminated line causes crash #308

@gergelypeli

Description

@gergelypeli

If a database file only contains one line with the column type definitions, it is only parsed correctly (as an empty table) if the file ends with a newline. If not, loading the file crashes opensips.

I looked at a gdb backtrace, but not investigated it any further.

Program terminated with signal 11, Segmentation fault.
#0  dbt_get_refs (_dtp=0x7f45d03655d8, _k=0x7fffbaf8f870, _n=6) at dbt_res.c:169
169                             if(_k[i]->len==_dtp->colv[j]->name.len
(gdb) bt
#0  dbt_get_refs (_dtp=0x7f45d03655d8, _k=0x7fffbaf8f870, _n=6) at dbt_res.c:169
#1  0x00007f45d39cd7a8 in dbt_query (_h=0x7f45d3fef940, _k=<optimized out>, _op=0x0, _v=0x0, _c=0x7fffbaf8f870, _n=0, _nc=6, _o=0x0,
    _r=0x7fffbaf8f8e0) at dbt_base.c:208
#2  0x00007f45d26dd418 in ds_reload_db () from /usr/lib/opensips/modules/dispatcher.so
#3  0x00007f45d26df341 in ?? () from /usr/lib/opensips/modules/dispatcher.so
#4  0x000000000046e411 in ?? ()
#5  0x000000000046e3a9 in ?? ()
#6  0x000000000042e702 in main ()

Using version 1.11.

As a related issue: if a table has records, but the last record's line is unterminated, that record is silently ignored.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions