]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
md5sum: fix --text with the MSYS2 runtime
authorPádraig Brady <P@draigBrady.com>
Fri, 7 Nov 2025 13:55:39 +0000 (13:55 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 12 Nov 2025 14:11:27 +0000 (14:11 +0000)
Note the use of "rt" is non-standard, but we're restricting
its use here to systems that define O_BINARY, which should
invariably support "rt" mode.

* src/digest.c (): Where significant, explicitly use "rt" mode
with --text, as MSYS2 defaults to binary mode for fopen'd files
(though not for standard streams).
* NEWS: Mention the bug fix.
Fixes https://github.com/coreutils/coreutils/issues/123

NEWS
src/digest.c

diff --git a/NEWS b/NEWS
index e334a07fa3461e520d944e16500841bc8d8f35de..61d78425284bc3863c6bf1a486cd932f8203feeb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  md5sum --text correctly translates CRLF line endings with the MSYS2 runtime.
+  This also applies to the sha*sum and b2sum utilities.
+  [This bug was present in "the beginning".]
+
 
 * Noteworthy changes in release 9.9 (2025-11-10) [stable]
 
index 58b9c9ec1f51dba84b2fd3bfbaefeb3256674f1d..f330bc1e93fe1405c99633f6e3020a42d5bdfaa9 100644 (file)
@@ -1121,7 +1121,7 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result,
     }
   else
     {
-      fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r"));
+      fp = fopen (filename, O_BINARY ? (*binary ? "rb" : "rt") : "r");
       if (fp == nullptr)
         {
           if (ignore_missing && errno == ENOENT)