From nobody@FreeBSD.org  Sun Feb 25 02:07:42 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 74FF537B491
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 25 Feb 2001 02:07:41 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f1PA7fE17674;
	Sun, 25 Feb 2001 02:07:41 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200102251007.f1PA7fE17674@freefall.freebsd.org>
Date: Sun, 25 Feb 2001 02:07:41 -0800 (PST)
From: juraj@bednar.sk
To: freebsd-gnats-submit@FreeBSD.org
Subject: Libmcrypt crashes under certain circumstances (FreeBSD specific)
X-Send-Pr-Version: www-1.0

>Number:         25352
>Category:       ports
>Synopsis:       Libmcrypt crashes under certain circumstances (FreeBSD specific)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 25 02:10:01 PST 2001
>Closed-Date:    Tue Apr 3 03:03:59 PDT 2001
>Last-Modified:  Tue Apr 03 03:04:40 PDT 2001
>Originator:     Juraj bednar
>Release:        4.2-STABLE (recent build)
>Organization:
>Environment:
FreeBSD ephex.factory.sk 4.2-STABLE FreeBSD 4.2-STABLE #3: Thu Feb 22 21:17:43 CET 2001     root@ephex.factory.sk:/usr/obj/usr/src/sys/EPHEX  i386

>Description:
Libmcrypt crashes when trying under PHP. I contacted Derick from the PHP team, gave him an
account on the machine and we debugged it together. He told, that this is Libmcrypt, not
PHP problem. Anyway, the same configuration and script runs under linux and other
operating systems. I tried versions 2.4.4 up to 2.4.9 of libmcrypt. 
>How-To-Repeat:
Compile mod_php4 with libmcrypt enabled and run this snippet of code in it:

      function make_tatra_sign( $value, $key) {

        // get the SHA1
        $hash = substr(mhash (MHASH_SHA1, $value), 0, 8);

        // encrypt hash with key
        $td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $signature = strtoupper(bin2hex(mcrypt_generic ($td, $hash)));
        mcrypt_generic_end ($td);

        return $signature;
      }

this gives the following backtrace:


                      #0  0x0 in ?? ()
                      #1  0x2842fa4a in mcrypt_enc_is_block_algorithm_mode () from /usr/local/lib/libmcrypt.so.5
                      #2  0x2842f4a9 in mcrypt_module_open () from /usr/local/lib/libmcrypt.so.5
                      #3  0x28334b87 in php_if_mcrypt_module_open (ht=4, return_value=0x827d20c, this_ptr=0x0,
                          return_value_used=1) at mcrypt.c:417
                      #4  0x2830fa09 in execute (op_array=0x828360c) at ./zend_execute.c:1519
                      #5  0x2830fc5c in execute (op_array=0x828380c) at ./zend_execute.c:1559
                      #6  0x2830fc5c in execute (op_array=0x828390c) at ./zend_execute.c:1559
                      #7  0x2830fc5c in execute (op_array=0x8283a0c) at ./zend_execute.c:1559
                      #8  0x2830fc5c in execute (op_array=0x825fc0c) at ./zend_execute.c:1559
                      #9  0x2831dc4e in zend_execute_scripts (type=8, file_count=3) at zend.c:729
                      #10 0x2832f0e4 in php_execute_script (primary_file=0xbfbff958) at main.c:1221
                      #11 0x2832b9e2 in apache_php_module_main (r=0x8269038, display_source_mode=0) at
                      sapi_apache.c:89
                      #12 0x2832c382 in send_php (r=0x8269038, display_source_mode=0, filename=0x0) at
                      mod_php4.c:516
                      #13 0x2832c3be in send_parsed_php (r=0x8269038) at mod_php4.c:527
                      #14 0x80536f8 in ap_invoke_handler ()
                      #15 0x80626b1 in process_request_internal ()
                      #16 0x8062710 in ap_process_request ()
                      #17 0x805c012 in child_main ()
                      #18 0x805c1a4 in make_child ()
                      #19 0x805c2c1 in startup_children ()
                      #20 0x805c790 in standalone_main ()
                      #21 0x805ce4b in main ()
                      #22 0x804fbf1 in _start ()

The PHP bug report announce is here:
http://bugs.php.net/bugs.php?id=9383&edit=1

Anyway, people don't like to fix this, as this is freebsd-only related.
>Fix:

>Release-Note:
>Audit-Trail:

From: Juraj Bednar <juraj@bednar.sk>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: ports/25352: Libmcrypt crashes under certain circumstances (FreeBSD specific)
Date: Tue, 27 Feb 2001 00:14:10 +0100

 I've done some research. This code fails to run (segfaults with the
 same symptoms as PHP):
 
 #include<mcrypt.h>
 
 main() {
 mcrypt_module_open("tripledes","/usr/local/lib/libmcrypt/algorithms","ecb","/usr/local/lib/libmcryp
 t/modes");
 }
 
 Anyway, what's interesting -> I have the module tripledes installed
 correctly (even in that directory). But even the bundled ciphertest
 program does not find any working algorithms under freebsd 4.2.
 Everything works under Linux, so this is probably portability issue.
 
 This is the stack trace of the above program crashing:
 
 #0  0x0 in ?? ()
 #1  0x2806831d in mcrypt_enc_is_block_algorithm_mode (td=0x804b000) at
 mcrypt_modules.c:436
 #2  0x28067a70 in mcrypt_module_open (algorithm=0x8048604 "tripledes",
     a_directory=0x80485e0 "/usr/local/lib/libmcrypt/algorithms",
 mode=0x80485bf "ecb",
     m_directory=0x80485a0 "/usr/local/lib/libmcrypt/modes") at
 mcrypt_modules.c:169
 #3  0x804852b in main () at test.c:5
 #4  0x8048471 in _start ()
 
 Anyway, now I'm really sure, this is freebsd-specific.
 

From: "KATO Tsuguru" <tkato@prontomail.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org
Cc: juraj@bednar.sk, vanilla@FreeBSD.org
Subject: Re: ports/25352: Libmcrypt crashes under certain circumstances (FreeBSD specific)
Date: Tue, 27 Feb 2001 19:31:05 +0900

 > Anyway, now I'm really sure, this is freebsd-specific.
 
 Actually, that is not architecture-specific issue.
 
 It's just the result of wrong opelation of processcing previous PR
 for updating libmcrypt. ports/25333 should be a solution.
 
 To confirm quickly, copy all lib*.la files included in modules
 directory of compiled libmcrypt source to installed modules directory
 ($PREFIX/lib/libmcrypt/modules/).
 
 
 -- 
 KATO Tsuguru / tkato@prontomail.ne.jp
                              
 Sent by Japanese ProntoMail
State-Changed-From-To: open->closed 
State-Changed-By: mharo 
State-Changed-When: Tue Apr 3 03:03:59 PDT 2001 
State-Changed-Why:  
PR 25333, which fixed this problem was committed on 3/14/2001 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25352 
>Unformatted:
