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