chiark / gitweb /
udev: fix test-udev binary
[elogind.git] / src / reply-password.c
index 24d73a798e2784a2b4340667bd5fbc599b8a482f..3a96049d7f8d767176b9c6c6791a899fcd09dd5c 100644 (file)
@@ -49,9 +49,9 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s
 
         zero(sa);
         sa.un.sun_family = AF_UNIX;
-        strncpy(sa.un.sun_path+1, socket_name, sizeof(sa.un.sun_path)-1);
+        strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
 
-        if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(socket_name)) < 0) {
+        if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
                 log_error("Failed to send: %m");
                 return -1;
         }
@@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
         char packet[LINE_MAX];
         size_t length;
 
-        log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
+        log_set_target(LOG_TARGET_AUTO);
         log_parse_environment();
         log_open();
 
@@ -82,7 +82,7 @@ int main(int argc, char *argv[]) {
                 }
 
                 truncate_nl(packet+1);
-                length = strlen(packet+1) + 1;
+                length = 1 + strlen(packet+1) + 1;
         } else if (streq(argv[1], "0")) {
                 packet[0] = '-';
                 length = 1;