mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Avoid importing env vars with invalid names (rhbz#1147645)
This imports a new version of the code to import environment variable values that was sent to Red Hat from upstream in 2014. It avoids importing environment variables whose names are not valid in the shell language, as it would be impossible to change or unset them. However, they stay in the environment to be passed to child processes. Prior discussion: https://bugzilla.redhat.com/1147645 Original patch:642af4d6/f/ksh-20120801-oldenvinit.patch
src/cmd/ksh93/sh/init.c: - env_init(): Import new, simplified code to import environment variable name/value pairs. Instead of doing the heavy lifting itself, this version uses nv_open(), passing the NV_IDENT flag to reject and skip invalid names. - Get rid of gotos and a static var by splitting off the code to import attributes into a new env_import_attributes() function. This is a better way to avoid importing attributes when initialising the shell in POSIX mode (re:00d43960
- Remove an nv_mapchar() call that was based on some unclear flaggery which was also removed by upstream as sent to Red Hat. I don't know what that did, if anything; looks like it might have had something to do with typeset -u/-l, but those particular attributes have never been successfully inherited through the environment. (Maybe that's another bug, or maybe I just don't care as inheriting attributes is a misfeature anyway; we have to put up with it because legacy scripts might use it. Maybe someone can prove it's an unacceptable security risk to import attributes like readonly from an environment variable that is inherently vulnerable to manipulation. That would be nice, as a CVE ID would give us a solid reason to get rid of this nonsense.) - Remove an 'else cp += 2;' that was very clearly a no-op; 'cp' is immediately overwritten on the next loop iteration and not used past the loop. src/cmd/ksh93/tests/variables.sh: - Test.
This commit is contained in:
parent
8a34fc40e6
commit
960a1a99cd
3 changed files with 48 additions and 72 deletions
4
NEWS
4
NEWS
|
@ -7,6 +7,10 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
|||
|
||||
- 'whence -f' now completely ignores the existence of functions, as documented.
|
||||
|
||||
- ksh now does not import environment variables whose names are not valid in
|
||||
the shell language, as it would be impossible to change or unset them.
|
||||
However, they stay in the environment to be passed to child processes.
|
||||
|
||||
2020-09-25:
|
||||
|
||||
- whence -v/-a now reports the path to the file that an "undefined" (i.e.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue