File 0004-server-Introduce-error-when-attempting-to-create-a-S.patch of Package wine

From 3ddd951cf2e4c89591c2a2958a98ba63de760d7e Mon Sep 17 00:00:00 2001
From: Ally Sommers <dropbear.sh@gmail.com>
Date: Tue, 16 May 2023 02:20:55 -0700
Subject: [PATCH 4/9] server: Introduce error when attempting to create a
 SOCK_DGRAM AF_UNIX socket.

---
 server/fd.c   | 10 ++--------
 server/sock.c |  6 ++++++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/server/fd.c b/server/fd.c
index ecb9bf570f2..0403d676e69 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1984,12 +1984,6 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
 
         if (fd->unix_fd == -1)
         {
-            if (stat( name, &st ))
-            {
-                file_set_error();
-                goto error;
-            }
-
             /* check for trailing slash on file path */
             if ((errno == ENOENT || (errno == ENOTDIR && !(options & FILE_DIRECTORY_FILE))) && name[strlen(name) - 1] == '/')
             {
@@ -2002,7 +1996,7 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
              * without lock support. Contrary to POSIX, Linux returns ENXIO in this
              * case, so we also check that error code here.
              */
-            else if ((errno == EOPNOTSUPP || errno == ENXIO) && S_ISSOCK(st.st_mode) && (options & FILE_DELETE_ON_CLOSE))
+            else if ((errno == EOPNOTSUPP || errno == ENXIO) && !stat(name, &st) && S_ISSOCK(st.st_mode) && (options & FILE_DELETE_ON_CLOSE))
                 ; /* no error, go to regular deletion code path */
             else
             {
@@ -2014,9 +2008,9 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
 
     fd->nt_name = dup_nt_name( root, nt_name, &fd->nt_namelen );
     fd->unix_name = NULL;
-    /* st was set from the file name if the file could not be opened */
     if (fd->unix_fd != -1)
         fstat( fd->unix_fd, &st );
+    /* st was set from the file name in case of sockets */
     *mode = st.st_mode;
 
     /* only bother with an inode for normal files and directories */
diff --git a/server/sock.c b/server/sock.c
index c3727b51d65..9c4aec16d84 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -1955,6 +1955,12 @@ static int init_socket( struct sock *sock, int family, int type, int protocol )
         return -1;
     }
 
+    if (unix_family == AF_UNIX && unix_type == SOCK_DGRAM)
+    {
+        set_win32_error(WSAEAFNOSUPPORT);
+        return -1;
+    }
+
     sockfd = socket( unix_family, unix_type, unix_protocol );
 
 #ifdef linux
-- 
2.50.0

openSUSE Build Service is sponsored by