From: Nicholas Clark Date: Fri, 3 Feb 2006 23:21:37 +0000 (+0000) Subject: S_find_beginning is only called from one place, so by hoisting the X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=faef540c8909a0bd99951f9de3e335c74b33dad1;p=p5sagit%2Fp5-mst-13.2.git S_find_beginning is only called from one place, so by hoisting the forbid_setid check for -x into the caller, we can eliminate the suidscript parameter from S_find_beginning. p4raw-id: //depot/perl@27076 --- diff --git a/embed.fnc b/embed.fnc index de210b0..48be268 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1134,7 +1134,7 @@ Ap |void |Slab_Free |NN void *op #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) -s |void |find_beginning |int suidscript +s |void |find_beginning s |void |forbid_setid |char flag|int suidscript s |void |incpush |NULLOK const char *dir|bool addsubdirs|bool addoldvers|bool usesep|bool canrelocate s |void |init_interp diff --git a/embed.h b/embed.h index 8918b0d..6432c4c 100644 --- a/embed.h +++ b/embed.h @@ -3188,7 +3188,7 @@ #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE -#define find_beginning(a) S_find_beginning(aTHX_ a) +#define find_beginning() S_find_beginning(aTHX) #define forbid_setid(a,b) S_forbid_setid(aTHX_ a,b) #define incpush(a,b,c,d,e) S_incpush(aTHX_ a,b,c,d,e) #define init_interp() S_init_interp(aTHX) diff --git a/perl.c b/perl.c index cf84f86..ad9eaf2 100644 --- a/perl.c +++ b/perl.c @@ -2050,7 +2050,13 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) || gMacPerl_AlwaysExtract #endif ) { - find_beginning(suidscript); + + /* This will croak if suidscript is >= 0, as -x cannot be used with + setuid scripts. */ + forbid_setid('x', suidscript); + /* Hence you can't get here if suidscript >= 0 */ + + find_beginning(); if (cddir && PerlDir_chdir( (char *)cddir ) < 0) Perl_croak(aTHX_ "Can't chdir to %s",cddir); } @@ -4218,7 +4224,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n"); } STATIC void -S_find_beginning(pTHX_ const int suidscript) +S_find_beginning(pTHX) { dVAR; register char *s; @@ -4229,11 +4235,6 @@ S_find_beginning(pTHX_ const int suidscript) /* skip forward in input to the real script? */ - /* This will croak if suidscript is >= 0, as -x cannot be used with - setuid scripts. */ - forbid_setid('x', suidscript); - /* Hence you can't get here if suidscript >= 0 */ - #ifdef MACOS_TRADITIONAL /* Since the Mac OS does not honor #! arguments for us, we do it ourselves */ diff --git a/proto.h b/proto.h index f445055..fc0186a 100644 --- a/proto.h +++ b/proto.h @@ -3167,7 +3167,7 @@ PERL_CALLCONV void Perl_Slab_Free(pTHX_ void *op) #endif #if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT) -STATIC void S_find_beginning(pTHX_ int suidscript); +STATIC void S_find_beginning(pTHX); STATIC void S_forbid_setid(pTHX_ char flag, int suidscript); STATIC void S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep, bool canrelocate); STATIC void S_init_interp(pTHX);