[Patches] [ python-Patches-574707 ] makesockaddr, use addrlen with AF_UNIX

noreply@sourceforge.net noreply@sourceforge.net
Thu, 27 Jun 2002 11:21:02 -0700


Patches item #574707, was opened at 2002-06-27 18: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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=574707&group_id=5470