PATCH: trailing nul bytes in abstract socket names

Havoc Pennington hp at redhat.com
Wed Sep 28 19:06:46 PDT 2005


On Wed, 2005-09-28 at 20:50 -0400, John (J5) Palmieri wrote:
>         */
>        addr.sun_path[0] = '\0'; /* this is what says "use abstract" */
>        strncpy (&addr.sun_path[1], path, _DBUS_MAX_SUN_PATH_LENGTH -
> 2);

This part should use path_len also since we are no longer using the full
length of sun_path, right?

> +      path_len++; /* add the extra NULL byte */ 

s/NULL/nul/

I think you're adding the nul byte at the front but not the nul
termination here... which may be right I guess.

> -  if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0)
> +  if (connect (fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET
> (struct sockaddr_un, sun_path) + path_len) < 0)

I'd say we also need a spec patch that discusses exactly which bytes are
included (e.g. whether or not nul termination is)

Havoc




More information about the dbus mailing list