Bug 71475

Summary: ACID (snort DB) detects versions incorrectly for PHP > v5.x
Product: Ports & Packages Reporter: David A. Koran <dak>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description David A. Koran 2004-09-07 22:30:17 UTC
in "acid_db_common.php" the detection routines for PHP versions are incorrect and need to revised.


----[section of code in question]----

function verify_php_build($DBtype)
/* Checks whether the necessary libraries is built into PHP */
{
  /* Check PHP version >= 4.0.4 */
  $current_php_version = phpversion();
  $version = explode(".", $current_php_version);

  /* account for x.x.xXX subversions possibly having text like 4.0.4pl1 */
  if ( is_numeric(substr($version[2], 1, 1)) )
     $version[2] = substr($version[2], 0, 2);
  else
     $version[2] = substr($version[2], 0, 1);

  /* only version PHP 4.0.4+ or 4.1+.* are valid */
  if ( !( ($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] >= 4) ) ||
                                    ($version[1] > 0)  ) ) )
  {
     return "<FONT COLOR=\"#FF0000\">PHP ERROR</FONT>: ".
            "<B>Incompatible version</B>: <FONT>Version ".$current_php_version.
            " of PHP is too old.  Please upgrade to version 4.0.4 or later</FONT>";
  }

Fix: 

I belive the problem lies within this comparison operator:

if ( !( ($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] >= 4) ) ||
                                    ($version[1] > 0)  ) ) )
How-To-Repeat: Try to configure ACID with a stock install of PHP5 on Apache 1.3
Comment 1 David A. Koran 2004-09-07 23:17:54 UTC
This fixes the version check, but now apache seg faults on the rest of 
the main acid code. Advisement... no PHP 5 and Acid

mail# diff acid_db_common.orig.php acid_db_common.php
67,68c67
<   if ( !( ($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] 
 >= 4) ) ||
<                                     ($version[1] > 0)  ) ) )
---
 > if ( ! ((($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] 
 >= 4) ) || ($version[1] > 0))) || (($version[0] >= 5) && ( ( 
($version[1] >= 0) && ($version[2] >= 0) ) )))   )
Comment 2 Ceri Davies freebsd_committer freebsd_triage 2004-09-08 11:47:19 UTC
On Tue, Sep 07, 2004 at 09:22:05PM +0000, David A. Koran wrote:
> 
> >Description:
> in "acid_db_common.php" the detection routines for PHP versions are incorrect and need to revised.
> 
> 
> ----[section of code in question]----
> 
> function verify_php_build($DBtype)
> /* Checks whether the necessary libraries is built into PHP */
> {
>   /* Check PHP version >= 4.0.4 */
>   $current_php_version = phpversion();
>   $version = explode(".", $current_php_version);
> 
>   /* account for x.x.xXX subversions possibly having text like 4.0.4pl1 */
>   if ( is_numeric(substr($version[2], 1, 1)) )
>      $version[2] = substr($version[2], 0, 2);
>   else
>      $version[2] = substr($version[2], 0, 1);
> 
>   /* only version PHP 4.0.4+ or 4.1+.* are valid */
>   if ( !( ($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] >= 4) ) ||
>                                     ($version[1] > 0)  ) ) )
>   {
>      return "<FONT COLOR=\"#FF0000\">PHP ERROR</FONT>: ".
>             "<B>Incompatible version</B>: <FONT>Version ".$current_php_version.
>             " of PHP is too old.  Please upgrade to version 4.0.4 or later</FONT>";
>   }
> 
> >How-To-Repeat:
> Try to configure ACID with a stock install of PHP5 on Apache 1.3
> >Fix:
> I belive the problem lies within this comparison operator:
> 
> if ( !( ($version[0] >= 4) && ( ( ($version[1] == 0) && ($version[2] >= 4) ) ||
>                                     ($version[1] > 0)  ) ) )

This sounds like a fault with the code of the application rather than
FreeBSD; could you report it to the author of the software if that's the
case?  The fix will then get pulled in with the next update of the port.

Ceri
-- 
It is not tinfoil, it is my new skin.  I am a robot.
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2004-10-05 07:37:41 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

Canonicalize assignment.
Comment 4 Volker Stolz freebsd_committer freebsd_triage 2005-09-16 09:09:07 UTC
State Changed
From-To: open->closed

Application bug, presumably not FreeBSD-specific. 
Please report this to the original authors. 
Thanks for your submission!