|
@@ -52,6 +52,7 @@ db1_con_t* dbt_init(const str* _sqlurl)
|
|
|
LM_ERR("invalid parameter value\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
+ LM_DBG("initializing for db url: [%.*s]\n", _sqlurl->len, _sqlurl->s);
|
|
|
_s.s = _sqlurl->s;
|
|
|
_s.len = _sqlurl->len;
|
|
|
if(_s.len <= DBT_ID_LEN || strncmp(_s.s, DBT_ID, DBT_ID_LEN)!=0)
|
|
@@ -68,16 +69,22 @@ db1_con_t* dbt_init(const str* _sqlurl)
|
|
|
_s.len -= DBT_ID_LEN;
|
|
|
if(_s.s[0]!='/')
|
|
|
{
|
|
|
- if(sizeof(CFG_DIR)+_s.len+2 > DBT_PATH_LEN)
|
|
|
+ if(sizeof(CFG_DIR)+_s.len+2 >= DBT_PATH_LEN)
|
|
|
{
|
|
|
LM_ERR("path to database is too long\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
strcpy(dbt_path, CFG_DIR);
|
|
|
- dbt_path[sizeof(CFG_DIR)] = '/';
|
|
|
- strncpy(&dbt_path[sizeof(CFG_DIR)+1], _s.s, _s.len);
|
|
|
- _s.len += sizeof(CFG_DIR);
|
|
|
+ if(dbt_path[sizeof(CFG_DIR)-2]!='/') {
|
|
|
+ dbt_path[sizeof(CFG_DIR)-1] = '/';
|
|
|
+ strncpy(&dbt_path[sizeof(CFG_DIR)], _s.s, _s.len);
|
|
|
+ _s.len += sizeof(CFG_DIR);
|
|
|
+ } else {
|
|
|
+ strncpy(&dbt_path[sizeof(CFG_DIR)-1], _s.s, _s.len);
|
|
|
+ _s.len += sizeof(CFG_DIR) - 1;
|
|
|
+ }
|
|
|
_s.s = dbt_path;
|
|
|
+ LM_DBG("updated db url: [%.*s]\n", _s.len, _s.s);
|
|
|
}
|
|
|
|
|
|
_res = pkg_malloc(sizeof(db1_con_t)+sizeof(dbt_con_t));
|