From 1fb215e991d260a128e35d761f6850e8d9e4c333 Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Fri, 18 Nov 2022 16:16:00 -0700 Subject: [PATCH] lib/pattern: Support binary pattern buffers on windows 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 Signed-off-by: Logan Gunthorpe Signed-off-by: Vincent Fu --- lib/pattern.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pattern.c b/lib/pattern.c index 1ae05758..9be29af6 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.25.1