Added patch to do a device check before returning a default serial port name.

This commit is contained in:
Sebastian Lackner 2016-01-05 06:06:58 +01:00
parent bf54f728cc
commit efffd311e9
5 changed files with 90 additions and 1 deletions

View File

@ -34,8 +34,9 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [1]:**
**Bug fixes and features included in the next upcoming release [2]:**
* Do a device check before returning a default serial port name ([Wine Bug #39793](https://bugs.winehq.org/show_bug.cgi?id=39793))
* Remove dead code from SCROLL_TrackScrollBar ([Wine Bug #39558](https://bugs.winehq.org/show_bug.cgi?id=39558))

View File

@ -0,0 +1,66 @@
From 9e643b1eb9f0050b72e17665fcc803756184637d Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Tue, 29 Dec 2015 00:48:02 -0700
Subject: ntdll: Do a device check before returning a default serial port name.
Fixes https://bugs.winehq.org/show_bug.cgi?id=39793
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
dlls/ntdll/directory.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index f3c6aa2..046f1b9 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -83,6 +83,9 @@
#ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h>
#endif
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
#include <time.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -321,6 +324,24 @@ static void flush_dir_queue(void)
}
}
+#ifdef linux
+/* Serial port device files almost always exist on Linux even if the corresponding serial
+ * ports don't exist. Do a basic functionality check before advertising a serial port. */
+static BOOL is_serial_device( const char *unix_name )
+{
+ struct termios tios;
+ BOOL ret = FALSE;
+ int fd;
+
+ if ((fd = open( unix_name, O_RDONLY )) != -1)
+ {
+ ret = tcgetattr( fd, &tios ) != -1;
+ close( fd );
+ }
+
+ return ret;
+}
+#endif
/***********************************************************************
* get_default_com_device
@@ -336,6 +357,11 @@ static char *get_default_com_device( int num )
ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/ttyS256") );
if (!ret) return NULL;
sprintf( ret, "/dev/ttyS%d", num - 1 );
+ if (!is_serial_device( ret ))
+ {
+ RtlFreeHeap( GetProcessHeap(), 0, ret );
+ ret = NULL;
+ }
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuau256") );
if (!ret) return NULL;
--
2.6.4

View File

@ -0,0 +1 @@
Fixes: [39793] Do a device check before returning a default serial port name

View File

@ -207,6 +207,7 @@ patch_enable_all ()
enable_ntdll_ProcessQuotaLimits="$1"
enable_ntdll_Purist_Mode="$1"
enable_ntdll_RtlIpStringToAddress="$1"
enable_ntdll_Serial_Port_Detection="$1"
enable_ntdll_Status_Mapping="$1"
enable_ntdll_Syscall_Wrappers="$1"
enable_ntdll_SystemRoot_Symlink="$1"
@ -735,6 +736,9 @@ patch_enable ()
ntdll-RtlIpStringToAddress)
enable_ntdll_RtlIpStringToAddress="$2"
;;
ntdll-Serial_Port_Detection)
enable_ntdll_Serial_Port_Detection="$2"
;;
ntdll-Status_Mapping)
enable_ntdll_Status_Mapping="$2"
;;
@ -4437,6 +4441,21 @@ if test "$enable_ntdll_RtlIpStringToAddress" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-Serial_Port_Detection
# |
# | This patchset fixes the following Wine bugs:
# | * [#39793] Do a device check before returning a default serial port name
# |
# | Modified files:
# | * dlls/ntdll/directory.c
# |
if test "$enable_ntdll_Serial_Port_Detection" -eq 1; then
patch_apply ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch
(
echo '+ { "Alex Henrie", "ntdll: Do a device check before returning a default serial port name.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Status_Mapping
# |
# | Modified files:

View File

@ -3,6 +3,8 @@ wine-staging (1.9.1) UNRELEASED; urgency=low
* Removed patch to align terminating null WCHAR in SysAllocStringByteLen
(accepted upstream).
* Added patch to remove dead code from SCROLL_TrackScrollBar.
* Added patch to do a device check before returning a default serial port
name.
-- Sebastian Lackner <sebastian@fds-team.de> Wed, 30 Dec 2015 01:03:12 +0100
wine-staging (1.9.0) unstable; urgency=low