Browse Source

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

The length of the buffer was not set, resulting in random failures.
Alex Hermann 14 years ago
parent
commit
fa71c18132
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/srdb1/db_ut.c

+ 3 - 1
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)
 int db_val2pv_spec(struct sip_msg* msg, db_val_t *dbval, pv_spec_t *pvs)
 {
 {
 	pv_value_t pv;
 	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)
 	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:
 			case DB1_BIGINT:
 				/* BIGINT is stored as string */
 				/* BIGINT is stored as string */
 				pv.flags = PV_VAL_STR;
 				pv.flags = PV_VAL_STR;
+				pv.rs.len = LL_LEN;
 				db_longlong2str(dbval->val.ll_val, ll_buf, &pv.rs.len);
 				db_longlong2str(dbval->val.ll_val, ll_buf, &pv.rs.len);
 				pv.rs.s = ll_buf;
 				pv.rs.s = ll_buf;
 			break;
 			break;