Skip to content

Commit

Permalink
app_jsdt: safety check for kemi func params used in log message
Browse files Browse the repository at this point in the history
- incresed size for local buffers
  • Loading branch information
miconda committed Jul 1, 2017
1 parent 1cc3f0d commit 84f7905
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/modules/app_jsdt/app_jsdt_mod.c
Expand Up @@ -192,15 +192,16 @@ int sr_kemi_config_engine_jsdt(sip_msg_t *msg, int rtype, str *rname,
return 1;
}

static char _jsdt_buf_stack[4][512];
#define JSDT_BUF_STACK_SIZE 1024
static char _jsdt_buf_stack[4][JSDT_BUF_STACK_SIZE];

/**
*
*/
static int ki_app_jsdt_dostring(sip_msg_t *msg, str *script)
{
if(script==NULL || script->s==NULL || script->len>=511) {
LM_ERR("script too short or too long %d\n", script->len);
if(script==NULL || script->s==NULL || script->len>=JSDT_BUF_STACK_SIZE-1) {
LM_ERR("script too short or too long %d\n", (script)?script->len:0);
return -1;
}
if(!jsdt_sr_initialized())
Expand Down Expand Up @@ -232,8 +233,8 @@ static int w_app_jsdt_dostring(struct sip_msg *msg, char *script, char *extra)
*/
static int ki_app_jsdt_dofile(sip_msg_t *msg, str *script)
{
if(script==NULL || script->s==NULL || script->len>=511) {
LM_ERR("script too short or too long %d\n", script->len);
if(script==NULL || script->s==NULL || script->len>=JSDT_BUF_STACK_SIZE-1) {
LM_ERR("script too short or too long %d\n", (script)?script->len:0);
return -1;
}
if(!jsdt_sr_initialized())
Expand Down Expand Up @@ -265,8 +266,8 @@ static int w_app_jsdt_dofile(struct sip_msg *msg, char *script, char *extra)
*/
static int ki_app_jsdt_runstring(sip_msg_t *msg, str *script)
{
if(script==NULL || script->s==NULL || script->len>=511) {
LM_ERR("script too short or too long %d\n", script->len);
if(script==NULL || script->s==NULL || script->len>=JSDT_BUF_STACK_SIZE-1) {
LM_ERR("script too short or too long %d\n", (script)?script->len:0);
return -1;
}
if(!jsdt_sr_initialized())
Expand Down Expand Up @@ -310,7 +311,7 @@ static int w_app_jsdt_run(struct sip_msg *msg, char *func, char *p1, char *p2,
LM_ERR("cannot get the function\n");
return -1;
}
if(s.len>=511)
if(s.len>=JSDT_BUF_STACK_SIZE-1)
{
LM_ERR("function too long %d\n", s.len);
return -1;
Expand All @@ -325,7 +326,7 @@ static int w_app_jsdt_run(struct sip_msg *msg, char *func, char *p1, char *p2,
LM_ERR("cannot get p1\n");
return -1;
}
if(s.len>=511)
if(s.len>=JSDT_BUF_STACK_SIZE-1)
{
LM_ERR("p1 too long %d\n", s.len);
return -1;
Expand All @@ -340,7 +341,7 @@ static int w_app_jsdt_run(struct sip_msg *msg, char *func, char *p1, char *p2,
LM_ERR("cannot get p2\n");
return -1;
}
if(s.len>=511)
if(s.len>=JSDT_BUF_STACK_SIZE-1)
{
LM_ERR("p2 too long %d\n", s.len);
return -1;
Expand All @@ -355,7 +356,7 @@ static int w_app_jsdt_run(struct sip_msg *msg, char *func, char *p1, char *p2,
LM_ERR("cannot get p3\n");
return -1;
}
if(s.len>=511)
if(s.len>=JSDT_BUF_STACK_SIZE-1)
{
LM_ERR("p3 too long %d\n", s.len);
return -1;
Expand Down

0 comments on commit 84f7905

Please sign in to comment.