Skip to content

Commit

Permalink
Merge pull request #3497 from sippy/pr_fix_3495
Browse files Browse the repository at this point in the history
python: Validate script_name a bit more carefully.
  • Loading branch information
bogdan-iancu authored Oct 18, 2024
2 parents 3df04c7 + 065448f commit e9f9e8e
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 e9f9e8e

Please sign in to comment.