Daniel Lehman : msvcrt: Set errno in _lseeki64.
Alexandre Julliard
julliard at winehq.org
Wed Oct 30 18:40:11 CDT 2019
Module: wine
Branch: master
Commit: 44b49f1a40f07f22209bd09eb415da233d8704ca
URL: https://source.winehq.org/git/wine.git/?a=commit;h=44b49f1a40f07f22209bd09eb415da233d8704ca
Author: Daniel Lehman <dlehman at esri.com>
Date: Tue Oct 29 09:46:31 2019 -0700
msvcrt: Set errno in _lseeki64.
Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/file.c | 1 +
dlls/msvcrt/tests/file.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 9075b432ff..825d442bfa 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -1265,6 +1265,7 @@ __int64 CDECL MSVCRT__lseeki64(int fd, __int64 offset, int whence)
if (info->handle == INVALID_HANDLE_VALUE)
{
+ *MSVCRT__errno() = MSVCRT_EBADF;
release_ioinfo(info);
return -1;
}
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 0ed59e347e..97d81abd00 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -2583,6 +2583,31 @@ static void test__creat(void)
p__set_fmode(old_fmode);
}
+static void test_lseek(void)
+{
+ int fd;
+ char testdata[4] = {'a', '\n', 'b', '\n'};
+
+ errno = 0xdeadbeef;
+ ok(_lseek(-42, 0, SEEK_SET) == -1, "expected failure\n");
+ ok(errno == EBADF, "errno = %d\n", errno);
+
+ fd = _creat("_creat.tst", _S_IWRITE);
+ ok(fd > 0, "_creat failed\n");
+ _write(fd, testdata, 4);
+
+ errno = 0xdeadbeef;
+ ok(_lseek(fd, 0, 42) == -1, "expected failure\n");
+ ok(errno == EINVAL, "errno = %d\n", errno);
+
+ errno = 0xdeadbeef;
+ ok(_lseek(fd, -42, SEEK_SET) == -1, "expected failure\n");
+ ok(errno == EINVAL, "errno = %d\n", errno);
+
+ _close(fd);
+ DeleteFileA("_creat.tst");
+}
+
START_TEST(file)
{
int arg_c;
@@ -2654,6 +2679,7 @@ START_TEST(file)
test_write_flush();
test_close();
test__creat();
+ test_lseek();
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
* file contains lines in the correct order
More information about the wine-cvs
mailing list