summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2026-05-23 05:25:10 +0200
committerMikael Magnusson <mikachu@gmail.com>2026-05-25 07:07:39 +0200
commit82a18fb3124420f4c0f6c953362d393b118501b8 (patch)
tree5e2a58f57485734c3b5791a503782ad1dc293970
parent54596: pathprog used a signed char as a buffer size (diff)
downloadzsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar.gz
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar.bz2
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar.lz
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar.xz
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.tar.zst
zsh-82a18fb3124420f4c0f6c953362d393b118501b8.zip
54597: hashcmd could reject valid paths to hash if they had metafied characters
And the iscom takes care of paths that are actually too long for us.
-rw-r--r--ChangeLog3
-rw-r--r--Src/exec.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index cc3946b47..a34d471c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2026-05-25 Mikael Magnusson <mikachu@gmail.com>
+ * 54597: Src/exec.c: hashcmd could reject valid paths to hash
+ if they had metafied characters
+
* 54596: Src/utils.c: pathprog used a signed char as a buffer size
* 54595: Src/exec.c: overflow check in isreallycom
diff --git a/Src/exec.c b/Src/exec.c
index 6c2ae8624..6b77f79a4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1043,7 +1043,7 @@ mod_export Cmdnam
hashcmd(char *arg0, char **pp)
{
Cmdnam cn;
- char *s, buf[PATH_MAX+1];
+ char *s, buf[MAXCMDLEN];
char **pq;
if (*arg0 == '/')
@@ -1051,9 +1051,9 @@ hashcmd(char *arg0, char **pp)
for (; *pp; pp++)
if (**pp == '/') {
s = buf;
- struncpy(&s, *pp, PATH_MAX);
+ struncpy(&s, *pp, sizeof(buf) - 1);
*s++ = '/';
- if ((s - buf) + strlen(arg0) >= PATH_MAX)
+ if ((s - buf) + strlen(arg0) >= sizeof(buf))
continue;
strcpy(s, arg0);
if (iscom(buf))