diff --git a/gio/gunixsocketaddress.c b/gio/gunixsocketaddress.c
index 89cc643..540b77c 100644
--- a/gio/gunixsocketaddress.c
+++ b/gio/gunixsocketaddress.c
@@ -96,10 +96,6 @@ g_unix_socket_address_set_property (GObject      *object,
 	  /* Clip to fit in UNIX_PATH_MAX with zero termination or first byte */
 	  len = MIN (array->len, UNIX_PATH_MAX-1);
 
-	  /* Remove any trailing zeros from path_len */
-	  while (len > 0 && array->data[len-1] == 0)
-	    len--;
-
 	  memcpy (address->priv->path, array->data, len);
 	  address->priv->path[len] = 0; /* Ensure null-terminated */
 	  address->priv->path_len = len;
@@ -156,7 +152,11 @@ g_unix_socket_address_get_family (GSocketAddress *address)
 static gssize
 g_unix_socket_address_get_native_size (GSocketAddress *address)
 {
-  return sizeof (struct sockaddr_un);
+  GUnixSocketAddress *addr = G_UNIX_SOCKET_ADDRESS (address);
+  if (addr->priv->abstract)
+    return G_STRUCT_OFFSET(struct sockaddr_un, sun_path) + addr->priv->path_len + 1;
+  else
+    return G_STRUCT_OFFSET(struct sockaddr_un, sun_path) + addr->priv->path_len;
 }
 
 static gboolean
@@ -275,7 +275,7 @@ g_unix_socket_address_new (const gchar *path)
 /**
  * g_unix_socket_address_new_abstract:
  * @path: the abstract name
- * @path_len: the length of @path, or -1
+ * @path_len: the length of @path, or -1 or -2
  *
  * Creates a new abstract #GUnixSocketAddress for @path.
  *
@@ -289,10 +289,17 @@ g_unix_socket_address_new (const gchar *path)
  * g_unix_socket_address_abstract_names_supported() to see if abstract
  * names are supported.
  *
+ * Note that abstract names need not be zero terminated and can have
+ * embedded NULs and that the length of the name is taking into
+ * consideration when determining equality - the abstract name
+ * "HELLO\0" differs from the abstract name "HELLO\0\0".
+ *
  * If @path_len is -1 then @path is assumed to be a zero terminated
- * string (although in general abstract names need not be zero terminated
- * and can have embedded nuls). All bytes after @path_len up to the max size
- * of an abstract unix domain name is filled with zero bytes.
+ * string. The name will not have any trailing NUL bytes
+ *
+ * If @path_len is -2 then @path is assumed to be a zero terminated
+ * string and the resulting name will be padded with NUL bytes up
+ * until the maximum length of the name.
  *
  * Returns: a new #GUnixSocketAddress
  *
@@ -305,12 +312,28 @@ g_unix_socket_address_new_abstract (const gchar *path,
   GSocketAddress *address;
   GByteArray *array;
 
-  if (path_len == -1)
-    path_len = strlen (path);
-
-  array = g_byte_array_sized_new (path_len);
-
-  g_byte_array_append (array, (guint8 *)path, path_len);
+  if (path_len >= 0)
+    {
+      array = g_byte_array_sized_new (path_len);
+      g_byte_array_append (array, (guint8 *)path, path_len);
+    }
+  else if (path_len == -1)
+    {
+      path_len = strlen (path);
+      array = g_byte_array_sized_new (path_len);
+      g_byte_array_append (array, (guint8 *) path, path_len);
+    }
+  else if (path_len == -2)
+    {
+      path_len = strlen (path);
+      array = g_byte_array_sized_new (UNIX_PATH_MAX);
+      g_byte_array_append (array, (guint8 *) path, path_len);
+      if (path_len < UNIX_PATH_MAX)
+        {
+          g_byte_array_set_size (array, UNIX_PATH_MAX);
+          memset (array->data, '\0', UNIX_PATH_MAX - path_len);
+        }
+    }
 
   address = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
 			  "path-as-array", array,
