From 4e411da35ff2d0250a5c0e2492181981f5a1857d Mon Sep 17 00:00:00 2001 From: "Wulf C. Krueger" Date: Mon, 30 Aug 2010 22:45:12 +0000 Subject: [PATCH] Fix failure in configure test for abstract sockets Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29895 Reviewed-by: Simon McVittie --- configure.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index ea110987..9debe3b8 100644 --- a/configure.in +++ b/configure.in @@ -694,6 +694,7 @@ AC_CACHE_CHECK([abstract socket namespace], #include ]], [[ + size_t slen; int listen_fd; struct sockaddr_un addr; @@ -708,9 +709,13 @@ AC_CACHE_CHECK([abstract socket namespace], memset (&addr, '\0', sizeof (addr)); addr.sun_family = AF_UNIX; strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test"); + /* SUN_LEN uses strlen() so need to calculate it before adding \0 at the + * beginning. + */ + slen = SUN_LEN(&addr); addr.sun_path[0] = '\0'; /* this is what makes it abstract */ - if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0) + if (bind (listen_fd, (struct sockaddr*) &addr, slen) < 0) { fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", strerror (errno)); -- 2.34.1