Skip to content

Commit

Permalink
Validate script_name a bit more carefully.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Oct 16, 2024
1 parent 2255334 commit 71e5d0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/python/python_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ mod_init(void)

bname = basename(script_name.s);
i = strlen(bname);
if (bname[i - 1] == 'c' || bname[i - 1] == 'o')
if (i > 4 && (bname[i - 1] == 'c' || bname[i - 1] == 'o'))
i -= 1;
if (bname[i - 3] == '.' && bname[i - 2] == 'p' && bname[i - 1] == 'y') {
if (i > 3 && memcmp(&bname[i - 3], ".py", 3) == 0) {
bname[i - 3] = '\0';
} else {
LM_ERR("%s: script_name doesn't look like a python script\n",
Expand Down

0 comments on commit 71e5d0a

Please sign in to comment.