|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81032 GD install is affected by external libgd installation
Submitted: 2021-05-11 23:51 UTC Modified: 2021-05-12 11:57 UTC
From: flaviohbatista at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: MacOS
Private report: No CVE-ID: None
 [2021-05-11 23:51 UTC] flaviohbatista at gmail dot com

When installing the GD extension using the bundled libgd, if any of the libraries used by libgd (e.g. libjpeg), are installed in a path that also happen to have a libgd installation, the extension code will include the external libgd files instead of the local ones.


1. Assume that `libjpeg` is installed at `/usr/local/include`;
2. Assume that `libgd` is also installed at `/usr/local/include`;
3. The build system will add `/usr/local/include` to CFLAGS (through pkg-config) for `libjpeg`;
3. Once you run `make`, you may end up in an error referring to `/usr/local/include/gd.h` instead of the bundled `gd.h`.

Root cause:

The bundled libgd fork includes `gd.h` and other gd-specific header files using `#include <foo.h>` rather than `#include "foo.h"`, which instructs the preprocessor to look for `foo.h` in the standard system directories and, if the file wasn't found, fall back to search in additional directories added to the search path.


Replace `#include <foo.h>` with `#include "foo.h"`, to ensure that the lookup will be executed in the local path first and then in the search path as fall back if the file was not found.

Actual result:
/Users/flavio/Documents/open-source/php-src/ext/gd/gd.c:571:48: error: implicit declaration of function 'gdPngGetVersionString' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        php_info_print_table_row(2, "libPNG Version", gdPngGetVersionString());
/Users/flavio/Documents/open-source/php-src/ext/gd/gd.c:571:48: note: did you mean 'gdVersionString'?
/usr/local/include/gd.h:1687:27: note: 'gdVersionString' declared here
BGD_DECLARE(const char *) gdVersionString(void);


gd.patch (last revision 2021-05-11 23:51 UTC by flaviohbatista at gmail dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-11 23:57 UTC]
-Assigned To: +Assigned To: cmb
 [2021-05-12 09:39 UTC]
The following pull request has been associated:

Patch Name: Fix bundled libgd includes
On GitHub:
 [2021-05-12 11:57 UTC]
-Status: Assigned +Status: Analyzed
 [2021-05-14 10:28 UTC]
Automatic comment on behalf of flavioheleno (author) and cmb69 (committer)
Log: Fix #81032: GD install is affected by external libgd installation
 [2021-05-14 10:28 UTC]
-Status: Analyzed +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 03:01:32 2024 UTC