summaryrefslogtreecommitdiffstats
path: root/Src/exec.c
diff options
context:
space:
mode:
authordana <dana@dana.is>2025-05-10 23:21:48 -0500
committerdana <dana@dana.is>2025-11-16 12:56:59 -0600
commita324ce344b5c57c4dc87c911e32ede7a586bd98d (patch)
tree9d97586491adca05705e07110e72ab81d64da47c /Src/exec.c
parent53577: _git: improve max-verbose, other descriptions (diff)
downloadzsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.gz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.bz2
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.lz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.xz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.zst
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.zip
53578 (tweaked): silence gcc warnings
addresses -Wmaybe-uninitialized and (spurious) -Wformat-overflow warnings omitted the change for zle_refresh.c since it was caught in w/54036
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/Src/exec.c b/Src/exec.c
index efc96d861..27bca110c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2922,7 +2922,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
struct multio *mfds[10];
char *text;
int save[10];
- int fil, dfil, is_cursh, do_exec = 0, redir_err = 0, i;
+ int fil, dfil, is_cursh = 0, do_exec = 0, redir_err = 0, i;
int nullexec = 0, magic_assign = 0, forked = 0, old_lastval;
int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0;
/* Various flags to the command. */
@@ -6255,12 +6255,14 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only)
pp = alt_path ? alt_path : fpath;
for (; *pp; pp++) {
- if (strlen(*pp) + strlen(s) + 1 >= PATH_MAX)
+ if (**pp) {
+ if (snprintf(buf, PATH_MAX, "%s/%s", *pp, s) >= PATH_MAX)
+ continue;
+ } else if (strlen(s) >= PATH_MAX) {
continue;
- if (**pp)
- sprintf(buf, "%s/%s", *pp, s);
- else
+ } else {
strcpy(buf, s);
+ }
if ((r = try_dump_file(*pp, s, buf, ksh, test_only))) {
if (fdir)
*fdir = *pp;
@@ -6408,12 +6410,14 @@ cancd(char *s)
return NULL;
if (!nocdpath)
for (cp = cdpath; *cp; cp++) {
- if (strlen(*cp) + strlen(s) + 1 >= PATH_MAX)
+ if (**cp) {
+ if (snprintf(sbuf, PATH_MAX, "%s/%s", *cp, s) >= PATH_MAX)
+ continue;
+ } else if (strlen(s) >= PATH_MAX) {
continue;
- if (**cp)
- sprintf(sbuf, "%s/%s", *cp, s);
- else
+ } else {
strcpy(sbuf, s);
+ }
if (cancd2(sbuf)) {
doprintdir = -1;
return dupstring(sbuf);