]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
be consistent about sun_path length
authorDavid Tardon <dtardon@redhat.com>
Tue, 9 Oct 2018 13:04:58 +0000 (15:04 +0200)
committerDavid Tardon <dtardon@redhat.com>
Fri, 12 Oct 2018 10:38:49 +0000 (12:38 +0200)
Most places use the whole buffer for name, without leaving extra space
for the trailing NUL.

src/core/manager.c
src/login/pam_systemd.c
src/nspawn/nspawn.c

index 2dea89dc01f6b28c273d410a9ec77a581ade69a0..446648a265aaf4d94fb48ecff9c6fa4a227aa3ce 100644 (file)
@@ -892,7 +892,7 @@ static int manager_setup_notify(Manager *m) {
                 (void) mkdir_parents_label(m->notify_socket, 0755);
                 (void) unlink(m->notify_socket);
 
-                strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
+                strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path));
                 r = bind(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
                 if (r < 0)
                         return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
index 8464df122c403f4373bce752ba652372f80380f5..90ccbd7a830477be7baeeec450fd15eb8561f1ae 100644 (file)
@@ -160,7 +160,7 @@ static int get_seat_from_display(const char *display, const char **seat, uint32_
         r = socket_from_display(display, &p);
         if (r < 0)
                 return r;
-        strncpy(sa.un.sun_path, p, sizeof(sa.un.sun_path)-1);
+        strncpy(sa.un.sun_path, p, sizeof(sa.un.sun_path));
 
         fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
         if (fd < 0)
index 27547051c8bf4da21cfddb8a9b7beedc72147837..134c4c3b5d7d83729dab8581aa34e541fa9efd4c 100644 (file)
@@ -2826,7 +2826,7 @@ static int setup_sd_notify_child(void) {
         (void) mkdir_parents(NSPAWN_NOTIFY_SOCKET_PATH, 0755);
         (void) unlink(NSPAWN_NOTIFY_SOCKET_PATH);
 
-        strncpy(sa.un.sun_path, NSPAWN_NOTIFY_SOCKET_PATH, sizeof(sa.un.sun_path)-1);
+        strncpy(sa.un.sun_path, NSPAWN_NOTIFY_SOCKET_PATH, sizeof(sa.un.sun_path));
         r = bind(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
         if (r < 0) {
                 safe_close(fd);