Module: sip-router
Branch: master
Commit: 3cde37cf10795b4eb785ffd141a8b28e64864f5d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3cde37c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Feb 6 16:03:27 2014 +0100
db_cassandra: clone key in a zero-termniated local buffer
- rework from a patch by Jay Binks
---
modules/db_cassandra/dbcassa_base.cpp | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/modules/db_cassandra/dbcassa_base.cpp
b/modules/db_cassandra/dbcassa_base.cpp
index ffa9e3b..1a721bb 100644
--- a/modules/db_cassandra/dbcassa_base.cpp
+++ b/modules/db_cassandra/dbcassa_base.cpp
@@ -440,6 +440,7 @@ ColumnVecPtr cassa_translate_query(const db1_con_t* _h, const
db_key_t* _k,
int key_len=0, seckey_len = 0;
int no_kc, no_sec_kc;
dbcassa_table_p tbc;
+ char pk[256];
/** Lock table schema and construct primary and secondary key **/
if(_k) {
@@ -496,7 +497,14 @@ ColumnVecPtr cassa_translate_query(const db1_con_t* _h, const
db_key_t* _k,
} else { /* the table doesn't have any secondary key defined */
if(_c) {
for(int i=0; i< _nc; i++) {
- sp.column_names.push_back(_c[i]->s);
+ /*sp.column_names.push_back(_c[i]->s);*/
+ if(_c[i]->len>255) {
+ LM_ERR("column key is too long [%.*s]\n", _c[i]->len, _c[i]->s);
+ return ColumnVecPtr(NULL);
+ }
+ memcpy(pk, _c[i]->s, _c[i]->len);
+ pk[_c[i]->len] = '\0';
+ sp.column_names.push_back(pk);
LM_DBG("Query col: %s\n", _c[i]->s);
}
LM_DBG("get %d columns\n", _nc);