Skip to content

Commit

Permalink
perl: Fix PKG corruption in perl_exec_simple() (off-by-one)
Browse files Browse the repository at this point in the history
Credits to Kingsley Tart for the report!

Fixes #2666

(cherry picked from commit 38e67d4)
  • Loading branch information
liviuchircu committed Nov 23, 2021
1 parent 8aba9d3 commit cc50f82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/perl/perlfunc.c
Expand Up @@ -66,17 +66,17 @@ int perl_exec_simple(struct sip_msg* _msg, str *_fnc_s, str *_param_s)
return -1;
}
memcpy(args[0], _param_s->s, _param_s->len);
args[0][_param_s->len] = 0;
args[0][_param_s->len] = '\0';
} else
flags |= G_NOARGS;

fnc = pkg_malloc(_fnc_s->len);
fnc = pkg_malloc(_fnc_s->len+1);
if (!fnc) {
LM_ERR("No more pkg mem!\n");
return -1;
}
memcpy(fnc, _fnc_s->s, _fnc_s->len);
fnc[_fnc_s->len] = 0;
fnc[_fnc_s->len] = '\0';

if (perl_checkfnc(fnc)) {
LM_DBG("running perl function \"%s\"\n", fnc);
Expand Down

0 comments on commit cc50f82

Please sign in to comment.