chiark / gitweb /
fix a couple of AF_UNIX connect() calls
authorLennart Poettering <lennart@poettering.net>
Tue, 3 Apr 2012 17:24:12 +0000 (19:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 3 Apr 2012 17:24:12 +0000 (19:24 +0200)
src/bridge.c
src/log.c

index 1f7cf3a9b94dc6633f20425a68afbad05d2a4e09..bfb38a8bb4c8967976e32b82412b01ef41f2d45f 100644 (file)
@@ -160,7 +160,7 @@ int main(int argc, char *argv[]) {
         sa.un.sun_family = AF_UNIX;
         strncpy(sa.un.sun_path, "/run/dbus/system_bus_socket", sizeof(sa.un.sun_path));
 
-        if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1)) < 0) {
+        if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
                 log_error("Failed to connect: %m");
                 goto finish;
         }
index 949936762a14c91830bd917029afeca91a205b47..5b1721184e65362a5e2f119ee90d127ac98c0c9d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -151,7 +151,7 @@ static int log_open_syslog(void) {
                 goto fail;
         }
 
-        if (connect(syslog_fd, &sa.sa, sizeof(sa)) < 0) {
+        if (connect(syslog_fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
                 close_nointr_nofail(syslog_fd);
 
                 /* Some legacy syslog systems still use stream
@@ -163,7 +163,7 @@ static int log_open_syslog(void) {
                         goto fail;
                 }
 
-                if (connect(syslog_fd, &sa.sa, sizeof(sa)) < 0) {
+                if (connect(syslog_fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
                         r = -errno;
                         goto fail;
                 }