[sr-dev] git:master: dlg: keep dialog value 0-terminated in memory

Daniel-Constantin Mierla miconda at gmail.com
Fri Aug 22 15:59:52 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Aug 19 18:00:49 2014 +0200

dlg: keep dialog value 0-terminated in memory

- more flexibility in searching/matching

---

 modules/dialog/dlg_profile.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules/dialog/dlg_profile.c b/modules/dialog/dlg_profile.c
index 3ce4783..0fd32c2 100644
--- a/modules/dialog/dlg_profile.c
+++ b/modules/dialog/dlg_profile.c
@@ -509,7 +509,7 @@ int dlg_add_profile(dlg_cell_t *dlg, str *value, struct dlg_profile_table *profi
 
 	/* build new linker */
 	linker = (struct dlg_profile_link*)shm_malloc(
-		sizeof(struct dlg_profile_link) + (profile->has_value?value->len:0) );
+		sizeof(struct dlg_profile_link) + (profile->has_value?(value->len+1):0) );
 	if (linker==NULL) {
 		LM_ERR("no more shm memory\n");
 		goto error;
@@ -524,6 +524,7 @@ int dlg_add_profile(dlg_cell_t *dlg, str *value, struct dlg_profile_table *profi
 		linker->hash_linker.value.s = (char*)(linker+1);
 		memcpy( linker->hash_linker.value.s, value->s, value->len);
 		linker->hash_linker.value.len = value->len;
+		linker->hash_linker.value.s[value->len] = '\0';
 	}
 
 	/* add linker directly to the dialog and profile */




More information about the sr-dev mailing list