From efffd311e9bddf7ac4de86917e4468262261c22e Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 5 Jan 2016 06:06:58 +0100 Subject: [PATCH] Added patch to do a device check before returning a default serial port name. --- README.md | 3 +- ...e-check-before-returning-a-default-s.patch | 66 +++++++++++++++++++ .../ntdll-Serial_Port_Detection/definition | 1 + patches/patchinstall.sh | 19 ++++++ staging/changelog | 2 + 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch create mode 100644 patches/ntdll-Serial_Port_Detection/definition diff --git a/README.md b/README.md index 409c44e3..08c20a15 100644 --- a/README.md +++ b/README.md @@ -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)) diff --git a/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch b/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch new file mode 100644 index 00000000..a922a929 --- /dev/null +++ b/patches/ntdll-Serial_Port_Detection/0001-ntdll-Do-a-device-check-before-returning-a-default-s.patch @@ -0,0 +1,66 @@ +From 9e643b1eb9f0050b72e17665fcc803756184637d Mon Sep 17 00:00:00 2001 +From: Alex Henrie +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 +--- + 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 + #endif ++#ifdef HAVE_TERMIOS_H ++# include ++#endif + #include + #ifdef HAVE_UNISTD_H + # include +@@ -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 + diff --git a/patches/ntdll-Serial_Port_Detection/definition b/patches/ntdll-Serial_Port_Detection/definition new file mode 100644 index 00000000..95fe42a7 --- /dev/null +++ b/patches/ntdll-Serial_Port_Detection/definition @@ -0,0 +1 @@ +Fixes: [39793] Do a device check before returning a default serial port name diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index b5c5924b..d0e82fcd 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -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: diff --git a/staging/changelog b/staging/changelog index 48fe8b1c..ff160f0f 100644 --- a/staging/changelog +++ b/staging/changelog @@ -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 Wed, 30 Dec 2015 01:03:12 +0100 wine-staging (1.9.0) unstable; urgency=low