Module: sip-router Branch: master Commit: 1c3e761fbd087ee578ce305d89f6b8ee4e9ab79d URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1c3e761f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Sep 30 16:49:26 2013 +0200
app_perl: use local buffer to print dynamic string in pv_sprintf()
- avoid pkg malloc for temporary need - fix leak in case of fmt parse error, discovered on a report by Dragos Oancea
---
modules/app_perl/kamailioxs.xs | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/modules/app_perl/kamailioxs.xs b/modules/app_perl/kamailioxs.xs index 4947ab6..823c4fc 100644 --- a/modules/app_perl/kamailioxs.xs +++ b/modules/app_perl/kamailioxs.xs @@ -362,15 +362,11 @@ static inline int rewrite_ruri(struct sip_msg* _m, char* _s) */ char *pv_sprintf(struct sip_msg *m, char *fmt) { int buf_size = 4096; + char out[4096]; pv_elem_t *model; str s; - char *out = (char *)pkg_malloc(buf_size); char *ret = NULL;
- if (!out) { - LM_ERR("pv_sprintf: Memory exhausted!\n"); - return NULL; - }
s.s = fmt; s.len = strlen(s.s); if(pv_parse_format(&s, &model) < 0) { @@ -386,7 +382,6 @@ char *pv_sprintf(struct sip_msg *m, char *fmt) { }
pv_elem_free_all(model); - pkg_free(out);
return ret; }