Skip to content

Commit

Permalink
Merge pull request #273 from rurban/master
Browse files Browse the repository at this point in the history
Fix perl5i.c #269 to avoid crash on a null byte in the command line.
  • Loading branch information
schwern committed Jul 23, 2014
2 parents 772e3aa + baa8e6a commit d3622f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bin/perl5i.c.PL
Expand Up @@ -42,7 +42,7 @@ int main (int argc, char* argv[]) {
char* program;
int saw_dash_e = 0;
strcat(dash_m, "-Mperl5i::cmd=");
strcpy(dash_m, "-Mperl5i::cmd=");
strcat(dash_m, argv[0]);
perl_args[0] = (char *)perl_cmd;
Expand All @@ -52,10 +52,11 @@ int main (int argc, char* argv[]) {
char *dash_e = strchr(argv[i], 'e');
/* Its a one liner */
if( dash_e && strcmp(dash_e, "e") == 0
if( dash_e
&& dash_e > argv[i]
&& *(dash_e-1) == '-'
&& (strchr(argv[i], '-') == argv[i])
&& (strchr(argv[i], 'M') != argv[i]+1)
)
)
{
saw_dash_e = 1;
Expand Down

0 comments on commit d3622f3

Please sign in to comment.