[sr-dev] git:4.0: app_perl: use local buffer to print dynamic string in pv_sprintf()
Daniel-Constantin Mierla
miconda at gmail.com
Wed Oct 2 09:53:29 CEST 2013
Module: sip-router
Branch: 4.0
Commit: 9f3f494289ab25d2a4a35672e21d1b1c76cfbd6b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9f3f494289ab25d2a4a35672e21d1b1c76cfbd6b
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at 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
(cherry picked from commit 1c3e761fbd087ee578ce305d89f6b8ee4e9ab79d)
---
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;
}
More information about the sr-dev
mailing list