Fix binary file detection

Resolves: #2135537
This commit is contained in:
Siteshwar Vashisht 2022-11-18 12:43:54 +01:00
parent c58d3fff91
commit 048bf61e43
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,29 @@
diff --git a/general.c b/general.c
--- a/general.c
+++ b/general.c
@@ -683,21 +683,20 @@ check_binary_file (sample, sample_len)
int sample_len;
{
register int i;
+ int nline;
unsigned char c;
if (sample_len >= 4 && sample[0] == 0x7f && sample[1] == 'E' && sample[2] == 'L' && sample[3] == 'F')
return 1;
/* Generally we check the first line for NULs. If the first line looks like
- a `#!' interpreter specifier, we just look for NULs anywhere in the
- buffer. */
- if (sample[0] == '#' && sample[1] == '!')
- return (memchr (sample, '\0', sample_len) != NULL);
+ a `#!' interpreter specifier, we look for NULs in the first two lines. */
+ nline = (sample[0] == '#' && sample[1] == '!') ? 2 : 1;
for (i = 0; i < sample_len; i++)
{
c = sample[i];
- if (c == '\n')
+ if (c == '\n' && --nline == 0)
return (0);
if (c == '\0')
return (1);

View File

@ -6,7 +6,7 @@
Version: %{baseversion}.%{patchlevel} Version: %{baseversion}.%{patchlevel}
Name: bash Name: bash
Summary: The GNU Bourne Again shell Summary: The GNU Bourne Again shell
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv3+ License: GPLv3+
Url: https://www.gnu.org/software/bash Url: https://www.gnu.org/software/bash
Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz
@ -89,6 +89,10 @@ Patch127: bash-4.4-no-loadable-builtins.patch
# This option is undocumented in upstream and is documented by this patch # This option is undocumented in upstream and is documented by this patch
Patch128: bash-5.0-syslog-history.patch Patch128: bash-5.0-syslog-history.patch
# 2135537 - Bash no longer executed a binary executable shell-script
# This patch should be removed during next rebase
Patch129: bash-5.2-file-detection.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: texinfo bison BuildRequires: texinfo bison
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
@ -320,6 +324,10 @@ end
%{_libdir}/pkgconfig/%{name}.pc %{_libdir}/pkgconfig/%{name}.pc
%changelog %changelog
* Fri Nov 18 2022 Siteshwar Vashisht <svashisht@redhat.com> - 5.2.9-2
- Fix binary file detection
Resolves: #2135537
* Fri Nov 18 2022 Siteshwar Vashisht <svashisht@redhat.com> - 5.2.9-1 * Fri Nov 18 2022 Siteshwar Vashisht <svashisht@redhat.com> - 5.2.9-1
- Update to bash-5.2 patchlevel 9 - Update to bash-5.2 patchlevel 9
Resolves: #2140722 Resolves: #2140722