summaryrefslogtreecommitdiffstats
path: root/source/a/bash/bash-5.2-patches/bash52-010
blob: b58f4a86b6ca079f55c87a066bbabb170e8c3409 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
			     BASH PATCH REPORT
			     =================

Bash-Release:	5.2
Patch-ID:	bash52-010

Bug-Reported-by:	larsh@apache.org
Bug-Reference-ID:
Bug-Reference-URL:	https://savannah.gnu.org/support/?110744

Bug-Description:

Bash-5.2 checks the first 128 characters of an executable file that execve()
refuses to execute to see whether it's a binary file before trying to
execute it as a shell script. This defeats some previously-supported use
cases like "self-executing" jar files or "self-uncompressing" scripts.

Patch (apply with `patch -p0'):

*** ../bash-5.2-patched/general.c	2022-11-07 10:31:42.000000000 -0500
--- general.c	2022-11-18 14:48:45.000000000 -0500
***************
*** 684,687 ****
--- 684,688 ----
  {
    register int i;
+   int nline;
    unsigned char c;
  
***************
*** 690,702 ****
  
    /* 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')
*** ../bash-5.2/patchlevel.h	2020-06-22 14:51:03.000000000 -0400
--- patchlevel.h	2020-10-01 11:01:28.000000000 -0400
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 9
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 10
  
  #endif /* _PATCHLEVEL_H_ */