diff options
| author | Mikael Magnusson <mikachu@gmail.com> | 2026-05-23 06:18:35 +0200 |
|---|---|---|
| committer | Mikael Magnusson <mikachu@gmail.com> | 2026-05-25 07:09:00 +0200 |
| commit | f21ea7321b977ec9a3e078e25ef8f5607cbf1797 (patch) | |
| tree | e901d820a82b4f17d24bc12089f17d02b55cba4d | |
| parent | 54597: hashcmd could reject valid paths to hash if they had metafied characters (diff) | |
| download | zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar.gz zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar.bz2 zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar.lz zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar.xz zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.tar.zst zsh-f21ea7321b977ec9a3e078e25ef8f5607cbf1797.zip | |
54598: fix getfpfunc metafication
It wouldn't load functions if they or the directory they were in had a
metafied byte in the name, for example れ has a 0x82 byte.
One detail to note here is the try_dump_file call using the unmetafied
ppu path, and then metafied function name s. That's correct because it's
comparing s with the function name inside the dumpfile, which is metafied.
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | Src/exec.c | 23 |
2 files changed, 16 insertions, 9 deletions
@@ -1,5 +1,7 @@ 2026-05-25 Mikael Magnusson <mikachu@gmail.com> + * 54598: Src/exec.c: fix getfpfunc metafication + * 54597: Src/exec.c: hashcmd could reject valid paths to hash if they had metafied characters diff --git a/Src/exec.c b/Src/exec.c index 6b77f79a4..95c8810a9 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -6259,29 +6259,34 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name) Eprog getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) { - char **pp, buf[PATH_MAX+1]; + char **pp, buf[PATH_MAX]; off_t len; off_t rlen; char *d; Eprog r; int fd; + char *su = unmeta(s); + if (su != s) su = dupstring(su); pp = alt_path ? alt_path : fpath; + char *ppu = ""; for (; *pp; pp++) { if (**pp) { - if (snprintf(buf, PATH_MAX, "%s/%s", *pp, s) >= PATH_MAX) + ppu = unmeta(*pp); + if (ppu != *pp) ppu = dupstring(ppu); + if (snprintf(buf, PATH_MAX, "%s/%s", ppu, su) >= PATH_MAX) continue; - } else if (strlen(s) >= PATH_MAX) { + } else if (strlen(su) >= PATH_MAX) { continue; } else { - strcpy(buf, s); + strcpy(buf, su); + ppu = ""; } - if ((r = try_dump_file(*pp, s, buf, ksh, test_only))) { + if ((r = try_dump_file(ppu, s, buf, ksh, test_only))) { if (fdir) - *fdir = *pp; + *fdir = ppu; return r; } - unmetafy(buf, NULL); if (!access(buf, R_OK) && (fd = open(buf, O_RDONLY | O_NOCTTY)) != -1) { struct stat st; if (!fstat(fd, &st) && S_ISREG(st.st_mode) && @@ -6289,7 +6294,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) if (test_only) { close(fd); if (fdir) - *fdir = *pp; + *fdir = ppu; return &dummy_eprog; } d = (char *) zalloc(len + 1); @@ -6306,7 +6311,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) scriptname = oldscriptname; if (fdir) - *fdir = *pp; + *fdir = ppu; zfree(d, len + 1); |
