[Wine-patches] ntdll: Use additional buffers in COMM_DeviceIoControl (eterbug #2827).

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Янв 23 18:07:36 MSK 2009


----------- следующая часть -----------
From 1b9f644886a719ec5248d3402263a25caf3a11f8 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 23 Jan 2009 18:01:28 +0300
Subject: [PATCH] ntdll: Use additional buffers in COMM_DeviceIoControl (eterbug #2827).

---
 dlls/ntdll/serial.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c
index 3fae4ac..55eeb77 100644
--- a/dlls/ntdll/serial.c
+++ b/dlls/ntdll/serial.c
@@ -1344,7 +1344,12 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
                               LPVOID lpInBuffer, DWORD nInBufferSize,
                               LPVOID lpOutBuffer, DWORD nOutBufferSize)
 {
-    NTSTATUS    status;
+    NTSTATUS    status = STATUS_NO_MEMORY;
+    void       *in_buff = RtlAllocateHeap(GetProcessHeap(), 0, nInBufferSize);
+    void       *out_buff = RtlAllocateHeap(GetProcessHeap(), 0, nOutBufferSize);
+
+    if (!in_buff || !out_buff) goto done;
+    memcpy(in_buff, lpInBuffer, nInBufferSize);
 
     if (dwIoControlCode == IOCTL_SERIAL_WAIT_ON_MASK)
     {
@@ -1369,8 +1374,8 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
             if (status) goto done;
         }
         status = io_control(hDevice, hev, UserApcRoutine, UserApcContext,
-                            piosb, dwIoControlCode, lpInBuffer, nInBufferSize,
-                            lpOutBuffer, nOutBufferSize);
+                            piosb, dwIoControlCode, in_buff, nInBufferSize,
+                            out_buff, nOutBufferSize);
         if (hev != hEvent)
         {
             if (status == STATUS_PENDING)
@@ -1382,8 +1387,14 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
         }
     }
     else status = io_control(hDevice, hEvent, UserApcRoutine, UserApcContext,
-                             piosb, dwIoControlCode, lpInBuffer, nInBufferSize,
-                             lpOutBuffer, nOutBufferSize);
+                             piosb, dwIoControlCode, in_buff, nInBufferSize,
+                             out_buff, nOutBufferSize);
 done:
+    if (in_buff) RtlFreeHeap(GetProcessHeap(), 0, in_buff);
+    if (out_buff)
+    {
+        memcpy(lpOutBuffer, out_buff, nOutBufferSize);
+        RtlFreeHeap(GetProcessHeap(), 0, out_buff);
+    }
     return status;
 }
-- 
1.6.0.2.GIT



Подробная информация о списке рассылки Wine-patches