teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0049-shared-handle-unnamed-sockets-in-socket_address_equa.patch

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