Skip to content

Commit

Permalink
cd: fix an invalid free() call (Solaris patch 211-21547336)
Browse files Browse the repository at this point in the history
This change is pulled from here:
https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/211-21547336.patch

src/cmd/ksh93/bltins/cd_pwd.c: b_cd():
- The functions path_pwd() and path_relative() in sh/path.c may
  return a pointer to e_dot[] (".") as a fallback if they fail to
  determine a path. This is a string in read-only memory
  (data/msg.c), so must not be freed. A pointer to that string may
  end up in sh.pwd (== shp->pwd), so b_cd() needs a check for that.
  • Loading branch information
McDutchie committed Jan 8, 2021
1 parent ad9ea0b commit a3ccff6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/bltins/cd_pwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context)
nv_scan(sh_subtracktree(1),rehash,(void*)0,NV_TAGGED,NV_TAGGED);
path_newdir(shp,shp->pathlist);
path_newdir(shp,shp->cdpathlist);
if(oldpwd)
if(oldpwd && oldpwd!=e_dot)
free(oldpwd);
return(0);
}
Expand Down

0 comments on commit a3ccff6

Please sign in to comment.