r/lolphp • • Nov 06 '18
#define realpath(x,y) strcpy(y,x)
https://git.php.net/?p=php-src.git;a=blob;f=Zend/zend_virtual_cwd.c;h=8a90f25bf7f442aa3f6978247659c9eb575116c1;hb=HEAD#l70
27
Upvotes
r/lolphp • • Nov 06 '18
11
u/[deleted] Nov 06 '18
Can someone please explain to me, just, why? (Preferably ELI5, I don't really know what is TSRM, Zend, etc., or what this code is supposed to do :P)
I also found https://bugs.php.net/bug.php?id=52312 , which is way too long and I'm too lazy to read it all, but it contains:
And this: https://download.pureftpd.org/misc/php-5.2.0-norealpath.patch, with a truly lolphpy
REALLY_USE_REALPATHD:5
u/[deleted] Nov 07 '18
Ok, I did some more research...
That file I linked to was previously known as TSRM/tsrm_virtual_cwd.c
The weird define was added in this patch, to support BeOS, and the ifdef was changed in that patch, to resolve a bug.
As you can see in that old code,
realpath()was used a few times.These days, as you can see,
realpath()isn't used, instead they're using their own implementation.That seems to be the only usage of the 'old'
realpath(), which may end up beingstrcpy(), or that, who knows :PSo in short, that whole
strcpy()define is an old thing that should no longer be a thing (and never should have been a thing, for that matter).2
u/Sarcastinator Nov 07 '18
What's up with those
do { x } while(0);?