[Patches] [ python-Patches-574707 ] makesockaddr, use addrlen with AF_UNIX
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 28 Jul 2002 09:25:11 -0700
Patches item #574707, was opened at 2002-06-27 20:21
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=574707&group_id=5470
Category: Modules
Group: Python 2.1.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Donn Cave (donnc)
Assigned to: Nobody/Anonymous (nobody)
Summary: makesockaddr, use addrlen with AF_UNIX
Initial Comment:
makesockaddr(), in 2.1 source, expects a NUL terminated string
in sockaddr_un.sun_path. That expectation is routinely not
met on some platforms - NetBSD 1.5.2, AIX 4.3.3, probably
others. This patch shows how to use addrlen to determine the
correct length of the value of sun_path.
Here's the diff (I have no idea what it means to "attach"
a file from my web browser), against 2.1 source.
*** socketmodule.c.dist Sun Apr 15 17:21:33 2001
--- socketmodule.c Thu Jun 27 11:09:57 2002
***************
*** 597,603 ****
case AF_UNIX:
{
struct sockaddr_un *a = (struct sockaddr_un *)
addr;
! return PyString_FromString(a->sun_path);
}
#endif
--- 597,605 ----
case AF_UNIX:
{
struct sockaddr_un *a = (struct sockaddr_un *)
addr;
! return PyString_FromStringAndSize(a->sun_path,
! addrlen -
! (sizeof(struct sockaddr_un) - sizeof(a
->sun_path)));
}
#endif
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-07-28 18:25
Message:
Logged In: YES
user_id=21627
This patch does not work. On systems where a NUL is
returned, this NUL is also accounted-for in addrlen, and
hence included in the string.
Would you like to revise your patch to support both cases?
Feel free to use the offsetof macro, btw.
Attaching a file is done by checking "Check to Upload and
Attach a File:" and adding a file name in the field below.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=574707&group_id=5470