diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-11-08 21:37:52 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-11-08 21:37:52 +0000 |
commit | 42d9b98d3f03094883cfc4bb765785a6d4396077 (patch) | |
tree | cb639739736f31b4c4068d5e3c9eb09b306d89fd /perl.c | |
parent | f7997f866fdcafc687fbaa99dbeb48f109b2e8d8 (diff) | |
download | perl-42d9b98d3f03094883cfc4bb765785a6d4396077.tar.gz |
Eliminate some unnecessary strlen()s
p4raw-id: //depot/perl@26050
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -3818,6 +3818,7 @@ S_validate_suid(pTHX_ const char *validarg, const char *scriptname) if (PL_statbuf.st_mode & (S_ISUID|S_ISGID)) { I32 len; const char *linestr; + const char *s_end; #ifdef IAMSUID if (PL_fdscript < 0 || PL_suidscript != 1) @@ -3923,7 +3924,8 @@ S_validate_suid(pTHX_ const char *validarg, const char *scriptname) s = linestr; /* PSz 27 Feb 04 */ /* Sanity check on line length */ - if (strlen(s) < 1 || strlen(s) > 4000) + s_end = s + strlen(s); + if (s_end == s || (s_end - s) > 4000) Perl_croak(aTHX_ "Very long #! line"); /* Allow more than a single space after #! */ while (isSPACE(*s)) s++; @@ -3962,7 +3964,8 @@ S_validate_suid(pTHX_ const char *validarg, const char *scriptname) len = strlen(validarg); if (strEQ(validarg," PHOOEY ") || strnNE(s,validarg,len) || !isSPACE(s[len]) || - !(strlen(s) == len+1 || (strlen(s) == len+2 && isSPACE(s[len+1])))) + !((s_end - s) == len+1 + || ((s_end - s) == len+2 && isSPACE(s[len+1])))) Perl_croak(aTHX_ "Args must match #! line"); #ifndef IAMSUID |