From 42d9b98d3f03094883cfc4bb765785a6d4396077 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 8 Nov 2005 21:37:52 +0000 Subject: Eliminate some unnecessary strlen()s p4raw-id: //depot/perl@26050 --- perl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'perl.c') diff --git a/perl.c b/perl.c index 3e7ccde944..40c86c2af9 100644 --- a/perl.c +++ b/perl.c @@ -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 -- cgit v1.2.1