PHP 4.0 Bug #6999 Updated: dirname() returns empty string for "/foo/"
| From: | Bug Database | Date: | Wed, 04 Oct 2000 02:37:31 +0000 |
| Subject: | PHP 4.0 Bug #6999 Updated: dirname() returns empty string for "/foo/" | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-34160@lists.php.net to get a copy of this message | ||
ID: 6999
Updated by: andi
Reported By: dolecek@ics.muni.cz
Status: Open
Bug Type: *General Issues
Assigned To:
Comments:
I think the main problem here is to decide what the behavior should be before we apply patches.
Is "/foo/" supposed to result in "/" or "/foo". I'm not sure what
the answer is. Maybe the author knows or we can decide according to when it's used. I
definitely am worried of making a change which will be backwards incompatible.
After we decide cleaning up that code and correcting it isn't a problem.
I'd like to hear feedback from others.
Previous Comments:
---------------------------------------------------------------------------
[2000-10-03 22:20:11] dolecek@ics.muni.cz
echo dirname("/foo/");
prints nothing (or empty string). It should print
"/foo".
The problem is in way php_dirname() in ext/standad/string.c
is handling trailing slashes. It strips all
trailing slashes. Then it finds last no stripped
slash (this leaves "/foo") and removes everything
after last slash (this leaves empty string, "").
The code should be changed so that this speical case
is treated correctly.
Also, the code seems to access invalid memory
if zero length string is passed (or do the PHP
strings always have length at least one, containing
'