Re: "cannot execute binary file" error with Bash 5.2

2022-11-18 Thread Chet Ramey

On 11/16/22 5:19 PM, Loïc Yhuel wrote:

https://savannah.gnu.org/support/index.php?110744

I attached the patch I applied.


It works, thank you.

Btw, I didn't search on savannah since
https://www.gnu.org/software/bash/manual/html_node/Reporting-Bugs.html
doesn't mention it.


Good idea; I should add it to the manual.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: "cannot execute binary file" error with Bash 5.2

2022-11-16 Thread Loïc Yhuel
> https://savannah.gnu.org/support/index.php?110744
>
> I attached the patch I applied.

It works, thank you.

Btw, I didn't search on savannah since
https://www.gnu.org/software/bash/manual/html_node/Reporting-Bugs.html
doesn't mention it.
But I see the bug tracker is mentioned on https://www.gnu.org/software/bash/.



Re: "cannot execute binary file" error with Bash 5.2

2022-11-15 Thread Chet Ramey

On 11/14/22 2:40 PM, loic.yh...@gmail.com wrote:


Bash Version: 5.2
Patch Level: 2
Release Status: release

Description:
 I can no longer run xxx-ct-ng.config scripts produced by crosstool-ng.
 Those just contain a few lines of script, with appended bzip2 
compressed text.
 
https://github.com/crosstool-ng/crosstool-ng/blob/master/scripts/toolchain-config.in
Bash 5.2 changed the check_binary_file function, it seems any NUL in 
the first
 80 characters will cause the error.

Repeat-By:
Create a test.sh with :
 #!/bin/sh
 tail -n+4 "${0}" | bzcat
 exit 0

 $ echo foo | bzip2 >> test.sh
 $ bash ./test.sh
 ./test.sh: ./test.sh: cannot execute binary file


https://savannah.gnu.org/support/index.php?110744

I attached the patch I applied.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
*** ../bash-5.2-patched/general.c   2021-11-04 14:12:38.0 -0400
--- general.c   2022-10-24 10:20:12.0 -0400
***
*** 682,685 
--- 684,688 
  {
register int i;
+   int nline;
unsigned char c;
  
***
*** 688,700 
  
/* 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);
  
for (i = 0; i < sample_len; i++)
  {
c = sample[i];
!   if (c == '\n')
return (0);
if (c == '\0')
--- 691,701 
  
/* Generally we check the first line for NULs. If the first line looks like
!  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' && --nline == 0)
return (0);
if (c == '\0')