mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	client: handle fcntl error on bad fd in wl_display_connect
This makes wl_display_connect fail immediately instead of succeeding when the integer provided by WAYLAND_SOCKET does not refer to a valid file descriptor. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
This commit is contained in:
		
							parent
							
								
									d564823cfd
								
							
						
					
					
						commit
						f00cfda737
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -1246,7 +1246,9 @@ wl_display_connect(const char *name)
 | 
				
			||||||
		errno = prev_errno;
 | 
							errno = prev_errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		flags = fcntl(fd, F_GETFD);
 | 
							flags = fcntl(fd, F_GETFD);
 | 
				
			||||||
		if (flags != -1)
 | 
							if (flags == -1 && errno == EBADF)
 | 
				
			||||||
 | 
								return NULL;
 | 
				
			||||||
 | 
							else if (flags != -1)
 | 
				
			||||||
			fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 | 
								fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 | 
				
			||||||
		unsetenv("WAYLAND_SOCKET");
 | 
							unsetenv("WAYLAND_SOCKET");
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue