From owner-freebsd-current Sun Oct 20 18:12:20 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id SAA08871 for current-outgoing; Sun, 20 Oct 1996 18:12:20 -0700 (PDT) Received: from cabri.obs-besancon.fr (cabri.obs-besancon.fr [193.52.184.3]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id SAA08861 for ; Sun, 20 Oct 1996 18:12:17 -0700 (PDT) Received: by cabri.obs-besancon.fr (5.57/Ultrix3.0-C) id AA09736; Mon, 21 Oct 96 03:18:14 +0100 Date: Mon, 21 Oct 96 03:18:14 +0100 Message-Id: <9610210218.AA09736@cabri.obs-besancon.fr> From: Jean-Marc Zucconi To: freebsd-current@freebsd.org Subject: socket (AF_UNIX) bug X-Mailer: Emacs Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk The following code creates a socket whose name is 1 char too short. A workaround is to add 1 to addrlen before calling bind, but I think that the code should work as is. #include #include #include #include main () { int s; struct sockaddr_un sockaddr; char path[256]; int addrlen; strcpy (path, "/tmp/zxyz"); unlink (path); s = socket (AF_UNIX, SOCK_STREAM, 0); memset ((void *)&sockaddr, 0, sizeof(sockaddr)); sockaddr.sun_family = AF_UNIX; strncpy (sockaddr.sun_path, path, sizeof(sockaddr.sun_path)); addrlen = sizeof(sockaddr.sun_family) + strlen(path); if (bind (s, (struct sockaddr *)&sockaddr, addrlen) < 0) perror ("bind"); system ("ls -l /tmp/zx*"); close (s); } Jean-Marc _____________________________________________________________________________ Jean-Marc Zucconi Observatoire de Besancon F 25010 Besancon cedex PGP Key: finger jmz@cabri.obs-besancon.fr =============================================================================