[sr-dev] git:master: lib/srdb1: fix conversion of longlong to string in db_val2pv_spec()

Alex Hermann alex at speakup.nl
Tue Sep 20 18:03:49 CEST 2011


Module: sip-router
Branch: master
Commit: fa71c181323448c934ac46ab9720e52783f62eb7
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fa71c181323448c934ac46ab9720e52783f62eb7

Author: Alex Hermann <alex at speakup.nl>
Committer: Alex Hermann <alex at speakup.nl>
Date:   Tue Sep 20 17:51:33 2011 +0200

lib/srdb1: fix conversion of longlong to string in db_val2pv_spec()

The length of the buffer was not set, resulting in random failures.

---

 lib/srdb1/db_ut.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/srdb1/db_ut.c b/lib/srdb1/db_ut.c
index 840c861..18c9bf8 100644
--- a/lib/srdb1/db_ut.c
+++ b/lib/srdb1/db_ut.c
@@ -407,7 +407,8 @@ int db_print_set(const db1_con_t* _c, char* _b, const int _l, const db_key_t* _k
 int db_val2pv_spec(struct sip_msg* msg, db_val_t *dbval, pv_spec_t *pvs)
 {
 	pv_value_t pv;
-	char ll_buf[21];  /* sign, 19 digits and \0 */
+#define LL_LEN 21   /* sign, 19 digits and \0 */
+	static char ll_buf[LL_LEN];
 
 	if(dbval->nul)
 	{
@@ -446,6 +447,7 @@ int db_val2pv_spec(struct sip_msg* msg, db_val_t *dbval, pv_spec_t *pvs)
 			case DB1_BIGINT:
 				/* BIGINT is stored as string */
 				pv.flags = PV_VAL_STR;
+				pv.rs.len = LL_LEN;
 				db_longlong2str(dbval->val.ll_val, ll_buf, &pv.rs.len);
 				pv.rs.s = ll_buf;
 			break;




More information about the sr-dev mailing list