bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libc/manual/examples/mkfsock.c `+ 1'


From: Michael Teichgräber
Subject: libc/manual/examples/mkfsock.c `+ 1'
Date: Wed, 20 Nov 2002 03:13:34 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-debian-linux-gnu)

Hi,

SUN_LEN computes the actual length of »sockaddr_un« as follows:

# define SUN_LEN(ptr) \
        ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
                             + strlen ((ptr)->sun_path))

A terminating null byte of (ptr)->sun_path does not go into this sum.
Shouldn't this be done in mkfsock.c the same way?:

------------------------------------------------>8----------
--- mkfsock.c.orig      Wed Nov 20 02:53:06 2002
+++ mkfsock.c   Wed Nov 20 02:53:22 2002
@@ -28,13 +28,12 @@ make_named_socket (const char *filename)
 
   /* The size of the address is
      the offset of the start of the filename,
-     plus its length,
-     plus one for the terminating null byte.
+     plus its length.
      Alternatively you can just do:
      size = SUN_LEN (&name);
   */
   size = (offsetof (struct sockaddr_un, sun_path)
-         + strlen (name.sun_path) + 1);
+         + strlen (name.sun_path));
 
   if (bind (sock, (struct sockaddr *) &name, size) < 0)
     {
----------8<------------------------------------------------


-- 
Michael




reply via email to

[Prev in Thread] Current Thread [Next in Thread]