Date: Wed, 11 Mar 92 15:03:42 PST
From: Minh Tran-Le <TRANLE@intellicorp.com>
Subject: Xlib: unaddr not initialized correctly in MakeUNIXSocketConnection.
Reply-to: tranle@intellicorp.com

### bug number:   5045
### area:         Xlib
### severity:     low
### comments:     

VERSION:
    R5, public-patch-9

CLIENT MACHINE and OPERATING SYSTEM:
    IBM RS6000/AIX 3.2

DISPLAY TYPE:
    SkyWay (gda0)

WINDOW MANAGER:
    mwm

COMPILER:
    native cc

AREA:
    Xlib

SYNOPSIS:
    The structure unaddr is not initialized correctly in the function
    MakeUNIXSocketConnection.

DESCRIPTION:
    The initialization of the unaddr.sun_len is not done in the
    the function MakeUNIXSocketConnection().  The sun_len field
    should be set to the length of the sun_path field.

    And the computation of addrlen the length of the sockaddr structure
    is also wrong because it assume that the structure has only 2
    field sun_family and sun_path.

REPEAT BY:
    Compile Xlib under AIX 3.2 and all the clients will fail to open
    the display :0.0.

SAMPLE FIX:
    Here is a context diff for my changes to mit/lib/XConnDis.c.
    The setting of unaddr.sun_len should really be conditionalized
    for AIX V3.2.

*** XConnDis.c-	Fri Sep 13 18:20:28 1991
--- XConnDis.c	Wed Mar 11 11:29:51 1992
***************
*** 442,450 ****
  
      unaddr.sun_family = AF_UNIX;
      sprintf (unaddr.sun_path, "%s%d", X_UNIX_PATH, idisplay);
  
      addr = (struct sockaddr *) &unaddr;
!     addrlen = strlen(unaddr.sun_path) + sizeof(unaddr.sun_family);
  
  #ifdef hpux /* this is disgusting */
      ounaddr.sun_family = AF_UNIX;
--- 442,451 ----
  
      unaddr.sun_family = AF_UNIX;
      sprintf (unaddr.sun_path, "%s%d", X_UNIX_PATH, idisplay);
+     unaddr.sun_len = strlen(unaddr.sun_path);
  
      addr = (struct sockaddr *) &unaddr;
!     addrlen = (sizeof(unaddr) - sizeof(unaddr.sun_path) + unaddr.sun_len);
  
  #ifdef hpux /* this is disgusting */
      ounaddr.sun_family = AF_UNIX;

-------

