Blame SOURCES/0025-cms-stdin2.patch

2871ff
From 9bdf6bb619543248c1bee1d8207b455c1ee40ab6 Mon Sep 17 00:00:00 2001
2871ff
From: Dmitry Belyavskiy <beldmit@gmail.com>
2871ff
Date: Fri, 20 Aug 2021 16:45:15 +0200
2871ff
Subject: [PATCH] Get rid of warn_binary
2871ff
2871ff
Current implementation of warn_binary introduces a regression
2871ff
when the content is passed in /dev/stdin as an explicit file name
2871ff
and reads the file to be processed twice otherwise.
2871ff
2871ff
I suggest to reimplement this functionality after 3.0 if necessary.
2871ff
2871ff
Fixes #16359
2871ff
---
2871ff
 apps/cms.c | 29 -----------------------------
2871ff
 1 file changed, 29 deletions(-)
2871ff
2871ff
diff --git a/apps/cms.c b/apps/cms.c
2871ff
index c22027e3b198..b30273f1710d 100644
2871ff
--- a/apps/cms.c
2871ff
+++ b/apps/cms.c
2871ff
@@ -272,31 +272,6 @@ static CMS_ContentInfo *load_content_info(int informat, BIO *in, int flags,
2871ff
     return NULL;
2871ff
 }
2871ff
 
2871ff
-static void warn_binary(const char *file)
2871ff
-{
2871ff
-    BIO *bio;
2871ff
-    unsigned char linebuf[1024], *cur, *end;
2871ff
-    int len;
2871ff
-
2871ff
-    if (file == NULL)
2871ff
-        return; /* cannot give a warning for stdin input */
2871ff
-    if ((bio = bio_open_default(file, 'r', FORMAT_BINARY)) == NULL)
2871ff
-        return; /* cannot give a proper warning since there is an error */
2871ff
-    while ((len = BIO_read(bio, linebuf, sizeof(linebuf))) > 0) {
2871ff
-        end = linebuf + len;
2871ff
-        for (cur = linebuf; cur < end; cur++) {
2871ff
-            if (*cur == '\0' || *cur >= 0x80) {
2871ff
-                BIO_printf(bio_err, "Warning: input file '%s' contains %s"
2871ff
-                           " character; better use -binary option\n",
2871ff
-                           file, *cur == '\0' ? "NUL" : "8-bit");
2871ff
-                goto end;
2871ff
-            }
2871ff
-        }
2871ff
-    }
2871ff
- end:
2871ff
-    BIO_free(bio);
2871ff
-}
2871ff
-
2871ff
 int cms_main(int argc, char **argv)
2871ff
 {
2871ff
     CONF *conf = NULL;
2871ff
@@ -911,8 +886,6 @@ int cms_main(int argc, char **argv)
2871ff
             goto end;
2871ff
     }
2871ff
 
2871ff
-    if ((flags & CMS_BINARY) == 0)
2871ff
-        warn_binary(infile);
2871ff
     in = bio_open_default(infile, 'r',
2871ff
                           binary_files ? FORMAT_BINARY : informat);
2871ff
     if (in == NULL)
2871ff
@@ -924,8 +897,6 @@ int cms_main(int argc, char **argv)
2871ff
             goto end;
2871ff
         if (contfile != NULL) {
2871ff
             BIO_free(indata);
2871ff
-            if ((flags & CMS_BINARY) == 0)
2871ff
-                warn_binary(contfile);
2871ff
             if ((indata = BIO_new_file(contfile, "rb")) == NULL) {
2871ff
                 BIO_printf(bio_err, "Can't read content file %s\n", contfile);
2871ff
                 goto end;