Module: kamailio Branch: master Commit: 2531dd069bc76f945c5c19253e35fe8b1ef9ed15 URL: https://github.com/kamailio/kamailio/commit/2531dd069bc76f945c5c19253e35fe8b1ef9ed15
Author: Holger Hans Peter Freyther <hol...@moiji-mobile.com> Committer: Holger Hans Peter Freyther <hol...@moiji-mobile.com> Date: 2016-10-25T23:01:14+02:00 pv: Use memcpy to copy len bytes instead of strcpy The sipcapture plugin stores bytes with VAR_VAL_STR and when copying the data it would end up being truncated. Use memcpy instead of strncpy and assume that the original string already has the NUL termination (or not as with the hep plugin). Config example: $var(payload) = hep(0x00f) --- Modified: modules/pv/pv_svar.c --- Diff: https://github.com/kamailio/kamailio/commit/2531dd069bc76f945c5c19253e35fe8b1ef9ed15.diff Patch: https://github.com/kamailio/kamailio/commit/2531dd069bc76f945c5c19253e35fe8b1ef9ed15.patch --- diff --git a/modules/pv/pv_svar.c b/modules/pv/pv_svar.c index 3b4c710..ae22db1 100644 --- a/modules/pv/pv_svar.c +++ b/modules/pv/pv_svar.c @@ -70,7 +70,7 @@ script_var_t* add_var(str *name, int vtype) return 0; } it->name.len = name->len; - strncpy(it->name.s, name->s, name->len); + memcpy(it->name.s, name->s, name->len); it->name.s[it->name.len] = '\0'; if(vtype==VAR_TYPE_NULL) { @@ -133,7 +133,7 @@ script_var_t* set_var_value(script_var_t* var, int_str *value, int flags) } var->v.flags |= VAR_VAL_STR; } - strncpy(var->v.value.s.s, value->s.s, value->s.len); + memcpy(var->v.value.s.s, value->s.s, value->s.len); var->v.value.s.len = value->s.len; var->v.value.s.s[value->s.len] = '\0'; } else { _______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev