php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66204 disabling XPM support in GD still enables gdImageCreateFromXpm() for PHP
Submitted: 2013-11-29 15:33 UTC Modified: 2013-11-29 17:29 UTC
From: rob dot de dot langhe at twistfare dot be Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.5.6 OS: Solaris-10
Private report: No CVE-ID: None
 [2013-11-29 15:33 UTC] rob dot de dot langhe at twistfare dot be
Description:
------------
We do not want to include X11 (XPM) support.

So we built the LIBGD library (version 2.1.0) with GCC (version 4.7.1) using both the flags "--with-xpm=no --without-xpm"
However the generated library "libgd.so.3.0.0" still contains a function "gdImageCreateFromXpm()" which is used by PHP to see if XPM is anyhow available in the "libgd" library:

When building the PHP version 5.5.6 using the flag "--with-xpm-dir=no" gives the following output from "configure" :
...
configure:37479: checking for the location of libXpm
configure:37494: result: no
...
configure:42617: checking for gdImageCreateFromXpm in -lgd
configure:42642: /our_base_dir/bin/gcc -o conftest -m32 -I/our_base_dir/include -fvisibility=hidden  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -L/our_base_dir/lib -lxml2 -m32 -R/usr/ucblib -L/usr/ucblib -R/our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -L/
our_base_dir/lib/gcc/sparc-sun-solaris2.10/4.7.1 -R/our_base_dir/lib -L/our_base_dir/lib conftest.c -lgd  -lgd -lpng -lz -lpng -lz -lz -lrt -lm -lnsl -lsocket  -lgcc -lxml2 -lz -lm -lso
cket -lnsl -lxml2 -lz -lm -lsocket -lnsl >&5
configure:42642: $? = 0
configure:42651: result: yes
...

With the "conftest.c" file containing a call to that function "gdImageCreateFromXpm()", to see if the compiler finds that function in the "libgd.so.3.0.0" library, which it does despite that we disabled the support for XPM in the building of LIBGD.

$ cat conftest.c
#ifdef __cplusplus
extern "C"
#endif
char gdImageCreateFromXpm ();
int
main ()
{
return gdImageCreateFromXpm ();
  ;
  return 0;
}

After "configure" is done, the "config.status" contains the flag
D["HAVE_GD_XPM"]=" 1"
so that PHP will attempt to build with X11 support, and fails during compilation because we do not (and don't want) have the X11 libraries installed:

$ make
...
/bin/bash /our_base_dir/src/php-5.5.6/libtool --silent --preserve-dup-deps --mode=compile /our_base_dir/bin/gcc -I/our_base_dir/include -Iext/gd/ -I/our_base_dir/src/php-5.5.6/ext/gd/ -DPHP_ATOM_INC -I/our_base_dir/src/php-5.5.6/include -I/our_base_dir/src/php-5.5.6/main -I/our_base_dir/src/php-5.5.6 -I/our_base_dir/src/php-5.5.6/ext/date/lib -I/our_base_dir/src/php-5.5.6/ext/ereg/regex -I/usr/include/libxml2 -I/our_base_dir/include -I/our_base_dir/src/php-5.5.6/ext/sqlite3/libsqlite -I/our_base_dir/src/php-5.5.6/TSRM -I/our_base_dir/src/php-5.5.6/Zend  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT  -m32 -I/our_base_dir/include -fvisibility=hidden -DZTS  -c /our_base_dir/src/php-5.5.6/ext/gd/gd.c -o ext/gd/gd.lo
/bin/bash /our_base_dir/src/php-5.5.6/libtool --silent --preserve-dup-deps --mode=compile /our_base_dir/bin/gcc -I/our_base_dir/include -Iext/gd/ -I/our_base_dir/src/php-5.5.6/ext/gd/ -DPHP_ATOM_INC -I/our_base_dir/src/php-5.5.6/include -I/our_base_dir/src/php-5.5.6/main -I/our_base_dir/src/php-5.5.6 -I/our_base_dir/src/php-5.5.6/ext/date/lib -I/our_base_dir/src/php-5.5.6/ext/ereg/regex -I/usr/include/libxml2 -I/our_base_dir/include -I/our_base_dir/src/php-5.5.6/ext/sqlite3/libsqlite -I/our_base_dir/src/php-5.5.6/TSRM -I/our_base_dir/src/php-5.5.6/Zend  -D_POSIX_PTHREAD_SEMANTICS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT  -m32 -I/our_base_dir/include -fvisibility=hidden -DZTS  -c /our_base_dir/src/php-5.5.6/ext/gd/gd_compat.c -o ext/gd/gd_compat.lo
/our_base_dir/src/php-5.5.6/ext/gd/gd.c:57:22: fatal error: X11/xpm.h: No such file or directory

Any idea how we can really force the disabling of XPM support in the libgd library ?


Expected result:
----------------
A way to really disable the XPM support in the libgd library.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-29 16:08 UTC] rob dot de dot langhe at twistfare dot be
The "libgd" library will apparently always contain a function "gdImageCreateFromXpm()", but which will return an error when it is called in case the building of "libgd" was done with "--with-xpm=no" :

in ./src/gdxpm.c :
...
#ifndef HAVE_LIBXPM
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
{
        (void)filename;
        gd_error_ex(GD_ERROR, "libgd was not built with xpm support\n");
        return NULL;
}
#else
...

So the check done by PHP with a linking of a test program to see if there is XPM support in the "libgd" library, despite the fact that the 'configure' flags "--without-xpm" or "--with-xpm-dir=no" were given, is incorrect. It will always return success, because that function "gdImageCreateFromXpm()" will always be in the libgd library file.
 [2013-11-29 17:29 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2013-11-29 17:29 UTC] pajoye@php.net
right, but you get the error in userland too.
 [2013-11-30 13:02 UTC] rob dot de dot langhe at twistfare dot be
If you consider this not to be a bug, where do you want me to report this (at least incorrect) behaviour ?
 [2015-06-20 00:27 UTC] iggyvolz at gmail dot com
This bug is still in PHP - it is impossible to install with GD without libXpm, as PHP will always report that it is installed even if it is not.  My workaround was to edit ext/gd/gd.c and remove all code that depended on HAVE_GD_XPM.
 [2015-07-07 02:58 UTC] uncle dot ziba at gmail dot com
Ran into this as well with version 5.6.10 on AIX.  I wonder if there is a more reliable way for the configure script to determine if the GD library has xmp support.

workaround in  the main/php_config.h comment out:

#define HAVE_GD_XPM 1

make clean; make
 [2019-05-24 18:00 UTC] admin at inwebse dot com
Up. Problem is still here. PHP version is 7.3.5.
 [2019-10-18 10:52 UTC] matthias dot bothe at freenet dot de
Got the same issue compiling php 7.1.32 from scratch for my old nas.
Workaround from 'uncle dot ziba at gmail dot com' worked for me, but IMHO this needs to be fixed.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 18:03:40 2021 UTC