[PATCH v3 5/6] lib/pattern: Support binary pattern buffers on windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On windows, binary files used as pattern buffers may be mangled or
truncated seeing the files are openned in text mode.

Fix this by passing O_BINARY on windows when openning the file.

Suggested-by: Vincent Fu <vincentfu@xxxxxxxxx>
Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
---
 lib/pattern.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/pattern.c b/lib/pattern.c
index 1ae05758f768..9be29af6bcf5 100644
--- a/lib/pattern.c
+++ b/lib/pattern.c
@@ -47,7 +47,11 @@ static const char *parse_file(const char *beg, char *out,
 	if (file == NULL)
 		goto err_out;
 
+#ifdef _WIN32
+	fd = open(file, O_RDONLY | O_BINARY);
+#else
 	fd = open(file, O_RDONLY);
+#endif
 	if (fd < 0)
 		goto err_free_out;
 
-- 
2.30.2




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux