summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2022-11-23 17:15:54 -0500
committerChet Ramey <chet.ramey@case.edu>2022-11-23 17:15:54 -0500
commit6014c93f34b3f1111f67ea9782850cde460968b4 (patch)
treea08041f3cdcd7395e44d2ed6cef12de4d9f7ebd8
parentfb0092fb0e7bb3121d3b18881f72177bcb765491 (diff)
downloadbash-6014c93f34b3f1111f67ea9782850cde460968b4.tar.gz
Bash-5.2 patch 10: slightly relax check for binary script files
-rw-r--r--general.c9
-rw-r--r--patchlevel.h2
2 files changed, 5 insertions, 6 deletions
diff --git a/general.c b/general.c
index 2bc9f382..bda39f41 100644
--- 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);
diff --git a/patchlevel.h b/patchlevel.h
index e59027ac..9ddc79f7 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 9
+#define PATCHLEVEL 10
#endif /* _PATCHLEVEL_H_ */