dcavalca / rpms / systemd

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