ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
1ff636
From 394185c013c15e47ffa1bdc5948ac6010c329728 Mon Sep 17 00:00:00 2001
1ff636
From: Michal Schmidt <mschmidt@redhat.com>
1ff636
Date: Fri, 20 Feb 2015 02:25:16 +0100
1ff636
Subject: [PATCH] shared: handle unnamed sockets in socket_address_equal()
1ff636
1ff636
Make sure we don't inspect sun_path of unnamed sockets.
1ff636
Since we cannot know if two unnamed sockets' adresses refer to the same
1ff636
socket, just return false.
1ff636
1ff636
(cherry picked from commit 710708a54ccc48e168ad7d4cd401645ef9e2eb14)
1ff636
---
1ff636
 src/shared/socket-util.c | 4 ++++
1ff636
 1 file changed, 4 insertions(+)
1ff636
1ff636
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
c62b8e
index deecce8a80..a4e26b1d8c 100644
1ff636
--- a/src/shared/socket-util.c
1ff636
+++ b/src/shared/socket-util.c
1ff636
@@ -349,6 +349,10 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
1ff636
                 break;
1ff636
 
1ff636
         case AF_UNIX:
1ff636
+                if (a->size <= offsetof(struct sockaddr_un, sun_path) ||
1ff636
+                    b->size <= offsetof(struct sockaddr_un, sun_path))
1ff636
+                        return false;
1ff636
+
1ff636
                 if ((a->sockaddr.un.sun_path[0] == 0) != (b->sockaddr.un.sun_path[0] == 0))
1ff636
                         return false;
1ff636