PHP 4.0 Bug #3956: Does not load a library
| From: | drew at elysium dot ltd dot uk | Date: | Wed, 29 Mar 2000 12:54:21 +0000 |
| Subject: | PHP 4.0 Bug #3956: Does not load a library | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-17343@lists.php.net to get a copy of this message | ||
From: drew@elysium.ltd.uk
Operating system: RH6.1 Intel
PHP version: 4.0 Beta 4 Patch Level 1
PHP Bug Type: Dynamic loading related
Bug description: Does not load a library
php.ini :-
extension_dir = /usr/lib/apache
extension = pgsql.so
After starting Apache, the following error appears in the error_log for Apache :-
PHP Fatal error: Unable to load dynamic library '/usr/lib/apache/mysql.so!' -
/usr/lib/apache/mysql.soA :No such file or directory in Unknown on line 0
The thing I noticed was the added ! and A on the library name in the error_log, it turns out it is
related to the fact the extension_dir in php.ini has not got a trailing / so the emalloc for libpath
in dl.c is wrong in this instance, the emalloc has a +1 for the 0 terminator but not any spare space
for the / added in the sprintf so the fix is to change the +1 to +2, or apply the following patch :-
(Note this bug is still there in RC1)
--- php-4.0RC1/ext/standard/dl.c.orig Wed Mar 29 13:34:49 2000
+++ php-4.0RC1/ext/standard/dl.c Wed Mar 29 13:35:03 2000
@@ -88,7 +88,7 @@
&& PG(extension_dir)[0]){
int extension_dir_len = strlen(PG(extension_dir));
- libpath = emalloc(extension_dir_len+file->value.str.len+1);
+ libpath = emalloc(extension_dir_len+file->value.str.len+2);
if (PG(extension_dir)[extension_dir_len-1]=='/' ||
PG(extension_dir)[extension_dir_len-1]=='\\') {
sprintf(libpath,"%s%s",PG(extension_dir),file->value.str.val);