[3/4] ntdll: Make NtWriteFile explicitly check for negative offset and fail. Resend.

Dmitry Timoshkov dmitry at baikal.ru
Tue Sep 10 06:20:22 CDT 2013


Currently it relies on pwrite to fail if negative offset is passed.
---
 dlls/ntdll/file.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 4e0a0ce..67520c5 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -985,6 +985,12 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
 
         if (off != (off_t)-2 /* FILE_USE_FILE_POINTER_POSITION */)
         {
+            if (off < 0)
+            {
+                status = STATUS_INVALID_PARAMETER;
+                goto done;
+            }
+
             /* async I/O doesn't make sense on regular files */
             while ((result = pwrite( unix_handle, buffer, length, off )) == -1)
             {
-- 
1.8.3.4




More information about the wine-patches mailing list