php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57463 crack_opendict() Returns "magic mismatch" on x86_64
Submitted: 2006-12-29 04:57 UTC Modified: 2017-10-24 06:18 UTC
From: imacat at mail dot imacat dot idv dot tw Assigned:
Status: Suspended Package: crack (PECL)
PHP Version: 5_2 CVS-2006-12-29 OS: Linux 2.6.16.29 x86_64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-12-29 04:57 UTC] imacat at mail dot imacat dot idv dot tw
Description:
------------
    Hi.  This is imacat from Taiwan.  I have reported a problem on static build before.  I saw you file it as #5763.

    I found that the PHP crack extension does not work on x86_64.  It returns "magic mismatch" when opening the dictionary.  The dictionary is fine, since pam_crack works with that dictionary.  I have tested this on my 2 x86_64 machines: The first one is Debian Sarge 3.1r4 AMD64, kernel 2.6.16.29, GCC 3.4.4, glibc 2.3.2, PHP 5.2.0.  The second is Debian Etch AMD64 d-i 2006-12-25, kernel 2.6.16.29, GCC 4.1.2, glibc 2.3.6, PHP 5.2.0.  The same code works fine on my i386/i686 machines.

Reproduce code:
---------------
#! /usr/bin/php
<?php
$dict = "/usr/share/dict/pw_dict";
$passwd1 = "analysis";
$passwd2 = "Dysk9queheoj";
echo "* crack_opendict(\"$dict\"):\n    ";
var_dump(crack_opendict($dict));
echo "* crack_check(\"$passwd1\"):\n    ";
var_dump(crack_check($passwd1));
echo "* crack_getlastmessage():\n    ";
var_dump(crack_getlastmessage());
echo "* crack_check(\"$passwd2\"):\n    ";
var_dump(crack_check($passwd2));
echo "* crack_getlastmessage():\n    ";
var_dump(crack_getlastmessage());
?>


Expected result:
----------------
On my i386/i686 machines:

imacat@leaf ~ % /tmp/test.php
* crack_opendict("/usr/share/dict/pw_dict"):
    resource(4) of type (crack dictionary)
* crack_check("analysis"):
    bool(false)
* crack_getlastmessage():
    string(32) "it is based on a dictionary word"
* crack_check("Dysk9queheoj"):
    bool(true)
* crack_getlastmessage():
    string(15) "strong password"
imacat@leaf ~ %


Actual result:
--------------
On my x86_64 machines:

imacat@atlas ~ % /tmp/test.php
* crack_opendict("/usr/share/dict/pw_dict"):
    /usr/share/dict/pw_dict: magic mismatch
PHP Warning:  crack_opendict(): Could not open crack dictionary: /usr/share/dict/pw_dict in /tmp/test.php on line 7

Warning: crack_opendict(): Could not open crack dictionary: /usr/share/dict/pw_dict in /tmp/test.php on line 7
bool(false)
* crack_check("analysis"):
    trying to open: /usr/share/dict/pw_dict
/usr/share/dict/pw_dict: magic mismatch
PHP Warning:  crack_check(): Could not open default crack dicionary in /tmp/test.php on line 9

Warning: crack_check(): Could not open default crack dicionary in /tmp/test.php on line 9
bool(false)
* crack_getlastmessage():
    PHP Warning:  crack_getlastmessage(): No obscure checks in this session in /tmp/test.php on line 11

Warning: crack_getlastmessage(): No obscure checks in this session in /tmp/test.php on line 11
bool(false)
* crack_check("Dysk9queheoj"):
    trying to open: /usr/share/dict/pw_dict
/usr/share/dict/pw_dict: magic mismatch
PHP Warning:  crack_check(): Could not open default crack dicionary in /tmp/test.php on line 13

Warning: crack_check(): Could not open default crack dicionary in /tmp/test.php on line 13
bool(false)
* crack_getlastmessage():
    PHP Warning:  crack_getlastmessage(): No obscure checks in this session in /tmp/test.php on line 15

Warning: crack_getlastmessage(): No obscure checks in this session in /tmp/test.php on line 15
bool(false)
imacat@atlas ~ %


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-30 23:48 UTC] nick at nickstallman dot net
I can confirm this bug. It refuses to open the dictionary on x86_64.

The system is a AMD AM2 X2 running Gentoo with PHP 5.1.6.
 [2008-01-07 05:49 UTC] hurclee at gmail dot com
Are there any upcoming patches or fixes to get crack working on the x86_64 systems.  From what I can find it looks to be an issue with the lib directory referenced opposed to the lib64.  If anyone has an idea on how to get this bug resolved it would be greatly appreciated.
 [2008-01-22 16:03 UTC] gregkiyomi at digitaljunkies dot ca
The problem is that there is a 32/64 bit size problem on AMD 64 systems.  The version of cracklib bundled in the pecl package improperly defines the following types in 

libcrack/src/cracklib.h:47:

typedef unsigned char int8;
typedef unsigned short int int16;
typedef unsigned long int32;

This results in int32 being 64 bits on an x86-64 machine because longs are 8 bytes long.  I changed this to:

typedef unsigned char int8;
typedef unsigned short int int16;
typedef unsigned int int32;

So that int32 is now actually 32 bits long.

It looks like the upstream version of crack does not suffer from these problems; it contains the following, which would work as well:

typedef u_int8_t int8;
typedef u_int16_t int16;
typedef u_int32_t int32;

Which are defined in sys/types.h.

(credit goes to Benj Carson for finding the problem and for the fix)
 [2008-07-17 06:12 UTC] tony at daylessday dot org
This was fixed in CVS long ago.
 [2015-10-26 20:07 UTC] rmf@php.net
-Status: Closed +Status: Assigned
 [2015-10-26 20:07 UTC] rmf@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: rmf
 [2015-10-26 20:10 UTC] rmf@php.net
Because something was fixed in CVS a decade ago doesn't mean it should be marked closed when it isn't available to users via PECL. Including in update that is forthcoming...working on the details of pushing to PECL.

For now: https://static.scribenet.com/rmf/crack-0.4.1.tar.xz
^ Also fixed https://bugs.php.net/bug.php?id=67818
 [2017-10-24 06:17 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: rmf +Assigned To:
 [2017-10-24 06:18 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-10-24 06:18 UTC] kalle@php.net
pecl/crack have not had a release for 12 years, so I'm gonna suspend this report, any future new maintainer can re-open this report
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC