diff options
author | Bart Schaefer <schaefer@zsh.org> | 2023-10-01 11:34:33 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2023-10-01 11:34:33 -0700 |
commit | 29644f12e742883ec9502205cffb318e446d7ca3 (patch) | |
tree | 34162573c0cda9dfcdfcfa04b5a42436214b1ff9 /Src | |
parent | 1b8446e1cd6dcd0644c1c96b952e11cbc472a24d (diff) | |
download | zsh-29644f12e742883ec9502205cffb318e446d7ca3.tar.gz zsh-29644f12e742883ec9502205cffb318e446d7ca3.tar.xz zsh-29644f12e742883ec9502205cffb318e446d7ca3.zip |
52193: handle UTF8-encoded USERNAME and therefore home directory in zcompile
Includes one unposted thinko fix ztrdup -> dupstring
Diffstat (limited to 'Src')
-rw-r--r-- | Src/init.c | 4 | ||||
-rw-r--r-- | Src/params.c | 2 | ||||
-rw-r--r-- | Src/parse.c | 12 | ||||
-rw-r--r-- | Src/utils.c | 2 |
4 files changed, 13 insertions, 7 deletions
diff --git a/Src/init.c b/Src/init.c index ffb017e22..799ad19f6 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1212,8 +1212,8 @@ setupvals(char *cmd, char *runscript, char *zsh_name) #ifdef USE_GETPWUID if ((pswd = getpwuid(cached_uid))) { if (EMULATION(EMULATE_ZSH)) - home = metafy(pswd->pw_dir, -1, META_DUP); - cached_username = ztrdup(pswd->pw_name); + home = ztrdup_metafy(pswd->pw_dir); + cached_username = ztrdup_metafy(pswd->pw_name); } else #endif /* USE_GETPWUID */ diff --git a/Src/params.c b/Src/params.c index 5841308d7..50e8627d1 100644 --- a/Src/params.c +++ b/Src/params.c @@ -4561,7 +4561,7 @@ usernamesetfn(UNUSED(Param pm), char *x) zwarn("failed to change user ID: %e", errno); else { zsfree(cached_username); - cached_username = ztrdup(pswd->pw_name); + cached_username = ztrdup_metafy(pswd->pw_name); cached_uid = pswd->pw_uid; } } diff --git a/Src/parse.c b/Src/parse.c index a07a6cc71..f7285c2ed 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -3217,12 +3217,14 @@ bin_zcompile(char *nam, char **args, Options ops, UNUSED(int func)) if (!args[1] && !(OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a'))) { queue_signals(); - ret = build_dump(nam, dyncat(*args, FD_EXT), args, OPT_ISSET(ops,'U'), + dump = unmetafy(dyncat(*args, FD_EXT), NULL); + ret = build_dump(nam, dump, args, OPT_ISSET(ops,'U'), map, flags); unqueue_signals(); return ret; } - dump = (strsfx(FD_EXT, *args) ? *args : dyncat(*args, FD_EXT)); + dump = (strsfx(FD_EXT, *args) ? dupstring(*args) : dyncat(*args, FD_EXT)); + unmetafy(dump, NULL); queue_signals(); ret = ((OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) ? @@ -3400,6 +3402,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags) for (hlen = FD_PRELEN, tlen = 0; *files; files++) { struct stat st; + char *fnam; if (check_cond(*files, "k")) { flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD; @@ -3408,7 +3411,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags) flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_ZSHLOAD; continue; } - if ((fd = open(*files, O_RDONLY)) < 0 || + fnam = unmeta(*files); + if ((fd = open(fnam, O_RDONLY)) < 0 || fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) || (flen = lseek(fd, 0, 2)) == -1) { if (fd >= 0) @@ -3417,8 +3421,10 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags) zwarnnam(nam, "can't open file: %s", *files); noaliases = ona; unlink(dump); + zsfree(fnam); return 1; } + zsfree(fnam); file = (char *) zalloc(flen + 1); file[flen] = '\0'; lseek(fd, 0, 0); diff --git a/Src/utils.c b/Src/utils.c index 7028c155f..790625379 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1069,7 +1069,7 @@ get_username(void) cached_uid = current_uid; zsfree(cached_username); if ((pswd = getpwuid(current_uid))) - cached_username = ztrdup(pswd->pw_name); + cached_username = ztrdup_metafy(pswd->pw_name); else cached_username = ztrdup(""); } |