chiark / gitweb /
Introduce loop_read_exact helper
[elogind.git] / src / shared / socket-util.c
index deecce8a8062da84ead7ec973323d0364ea8e84b..74d90fa2a9716df237aecc02f8098ccb4242f318 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <assert.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
-#include <stdlib.h>
 #include <arpa/inet.h>
 #include <stdio.h>
 #include <net/if.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <stddef.h>
-#include <sys/ioctl.h>
 #include <netdb.h>
 
 #include "macro.h"
-#include "util.h"
-#include "mkdir.h"
 #include "path-util.h"
+#include "util.h"
 #include "socket-util.h"
 #include "missing.h"
 #include "fileio.h"
@@ -349,6 +344,10 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
                 break;
 
         case AF_UNIX:
+                if (a->size <= offsetof(struct sockaddr_un, sun_path) ||
+                    b->size <= offsetof(struct sockaddr_un, sun_path))
+                        return false;
+
                 if ((a->sockaddr.un.sun_path[0] == 0) != (b->sockaddr.un.sun_path[0] == 0))
                         return false;