From 65e97f4826a57bb8fad05e1725e58de4acc88e89 Mon Sep 17 00:00:00 2001 From: fhgffy <102001626+fhgffy@users.noreply.github.com> Date: Mon, 5 Oct 2026 00:24:36 +0800 Subject: [PATCH] lzmainfo: Open named files in binary mode On native Windows, lzmainfo opened named .lzma files in text mode while stdin was already binary. The C runtime treats 0x1A as EOF and translates CRLF in the 13-byte header. A valid file with a known uncompressed size of 26 bytes failed with "File is too small to be a .lzma file"; a known size of 2573 bytes was incorrectly reported as 10 bytes. Reading the same files through stdin or - reported the correct sizes. Closes: https://github.com/tukaani-project/xz/pull/253 --- src/lzmainfo/lzmainfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lzmainfo/lzmainfo.c b/src/lzmainfo/lzmainfo.c index 0b0b0d3d..6d5f234d 100644 --- a/src/lzmainfo/lzmainfo.c +++ b/src/lzmainfo/lzmainfo.c @@ -219,7 +219,7 @@ main(int argc, char **argv) if (lzmainfo("(stdin)", stdin)) ret = EXIT_FAILURE; } else { - FILE *f = fopen(argv[optind], "r"); + FILE *f = fopen(argv[optind], "rb"); if (f == NULL) { ret = EXIT_FAILURE; fprintf(stderr, "%s: %s: %s\n",