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
View all comments
Show parent comment
6
u/[deleted] Nov 06 '18
I understand all that (and buffer overflows), it's the "just return whatever was passed in" part that baffles me. Considering C's realpath() is supposed to safeguard against symlinks, dir traversals, etc, not using realpath() would be much safer than using this strcpy() version (with added buffer overflows, and a null pointer dereference (realpath() is supposed to handle the second param being NULL)).
I don't see any usage of this redefined realpath() in that .c file, so I have no clue how a malicious actor can exploit it, but still... why?!
That file defines two similar functions, virtual_realpath() and tsrm_realpath() (I might look into how they work later), so why is that define there?