On Wed, 19 Apr 2006 14:50:07 +0000 (UTC) "Martin Nilsson (Opera Mini - AFK!) @ Pike (-) developers forum" 10353@lyskom.lysator.liu.se wrote:
In the function file_connect_unix(), Pike_sp[-args].u.string->len is checked against PATH_MAX, and then its strcpy'd into name.sun_path. The size of a sockaddr_un.sun_path isn't standard, and can be much smaller than PATH_MAX.
How should this be fixed, changing the PATH_MAX test to a sizeof(name.sun_path)? Or removing that check altogether, using strncpy and then checking for truncation and giving a "path too long" error instead of the current "Illegal argument. Expected string(8bit)"?
I think my vote is on a configure test for PATH_MAX.
Configure test for what about PATH_MAX? The problem is that PATH_MAX is defined as 1024 here, and sockaddr_un.sun is char[104] (although it could be any length). So testing against PATH_MAX doesn't do anything, it should be testing against sizeof(name.sun_path) instead.
Is it worth adding configure tests for strlcpy/cat and using those instead of strncpy/cat?
strlcpy is faster than strncpy, so we would like to use it when it exsits. Perhaps use a definition in port.h?
I've attached a patch to add STRLCPY and STRLCAT to port.c/h.
Adam