#41734 [NEW]: weak logic handling

From: Date: Tue, 19 Jun 2007 00:47:13 +0000
Subject: #41734 [NEW]: weak logic handling
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113913@lists.php.net to get a copy of this message
From: nomad at tekops dot com Operating system: linux PHP version: 5.2.3 PHP Bug Type: Scripting Engine problem Bug description: weak logic handling Description: ------------ While writing in PHP, I've been finding that your engine is not very good at keeping logic straight. simple if() statements break it, if they are one after another. If I put some other code between the if() statements, or nest them differently, it can figure it out. I have written compilers and language interpreters in the past, I am accustomed to writing flaw-free code in C and assembler. No kidding, I'm old school where we didn't have the luxury of errors, ram, or disk space. ---- In my sample code, I am simply checking the domains on an email address the user has entered into two fields on a form. My function gives me the correct answer, that the user (in my testing, that is me) has entered an email address with a domain that is not real. myCheckDNSRR() returns 'false'. In the first if() statement, it misses the false and barrels onward. the second if() statement fails as well, and barrels onward. The end result being, customer_service gets sent an email with a bogus user email address. If the email is bad, I just want the page to reload. I can get fancy, later. Reproduce code: --------------- /* saEmail1 & saEmail2 are email addresses posted to a form and submitted to this script (contact.php) */ $eValid = false; $eValid = myCheckDNSRR($saEmail1); /* See if emails are valid */ if($eValid == false) header("Location: <removed> /pages/contact.php"); $eValid = myCheckDNSRR($saEmail2); if($eValid == false) header("Location: <removed> /pages/contact.php"); Expected result: ---------------- $eValid = false; $eValid = myCheckDNSRR($saEmail1); /* See if emails are valid */ if($eValid == false) header("Location: <removed> /pages/contact.php"); die("$eValid: \t" . ($eValid==false?"false":"true") . "/r"); $eValid = myCheckDNSRR($saEmail2); if($eValid == false) header("Location: <removed> /pages/contact.php"); ---- NOTE THE ADDED 'DIE()' CALL (ABOVE) If I add this line in, the if above it works correctly and the screen refreshes if $eValid=false, or hits die() if it is 'true'. This tells me your engine has a flaw in the if() processing code. I've seen this several times. Actual result: -------------- If you want to send me the specific file that contains the code, I will happily see if I can fix it, and let you know where the problem is. -- Edit bug report at http://bugs.php.net/?id=41734&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41734&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41734&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41734&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41734&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41734&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41734&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41734&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41734&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41734&r=support Expected behavior: http://bugs.php.net/fix.php?id=41734&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41734&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41734&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41734&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41734&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41734&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41734&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41734&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41734&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41734&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41734&r=mysqlcfg

« previous php.bugs (#113913) next »