From 85a4cf9b36fe7cf876266a49950e80d00ca4c18f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 14 May 2015 09:28:57 +0100 Subject: 35110: don't implicitly initialize restricted integers to zero --- ChangeLog | 5 +++++ Doc/Zsh/params.yo | 18 ++++++++++++++++++ Src/builtin.c | 7 ++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5de510efb..02f6dd3e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-05-14 Peter Stephenson + + * 35110: Src/builtin.c, Doc/Zsh/params.yo: don't + implicitly initialize restricted integers to zero. + 2015-05-13 Oliver Kiddle * 35092: Src/Zle/zle_params.c: fix for numeric arguments diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 44df07cbc..eb3eb367e 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -642,6 +642,9 @@ privileges, you may change the effective group ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective group ID by `tt(LPAR()EGID=)var(gid)tt(; command+RPAR())' + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(EUID) item(tt(EUID) )( @@ -650,6 +653,9 @@ privileges, you may change the effective user ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective user ID by `tt(LPAR()EUID=)var(uid)tt(; command+RPAR())' + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(ERRNO) item(tt(ERRNO) )( @@ -666,6 +672,9 @@ you may change the group ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different group ID by `tt(LPAR()GID=)var(gid)tt(; command+RPAR())' + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(HISTCMD) item(tt(HISTCMD))( @@ -801,6 +810,9 @@ you may change the user ID of the shell by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different user ID by `tt(LPAR()UID=)var(uid)tt(; command+RPAR())' + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(USERNAME) item(tt(USERNAME) )( @@ -1098,6 +1110,9 @@ The maximum number of events stored in the internal history list. If you use the tt(HIST_EXPIRE_DUPS_FIRST) option, setting this value larger than the tt(SAVEHIST) size will give you the difference as a cushion for saving duplicated history events. + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(HOME) item(tt(HOME) )( @@ -1392,6 +1407,9 @@ It is expanded in the same way as tt(PS2). vindex(SAVEHIST) item(tt(SAVEHIST))( The maximum number of history events to save in the history file. + +If this is made local, it is not implicitly set to 0, but may be +explicitly set locally. ) vindex(SPROMPT) item(tt(SPROMPT) )( diff --git a/Src/builtin.c b/Src/builtin.c index 70e75ff17..18dad7491 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2344,7 +2344,12 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), pm->gsu.s->setfn(pm, ztrdup("")); break; case PM_INTEGER: - pm->gsu.i->setfn(pm, 0); + /* + * Restricted integers are dangerous to initialize to 0, + * so don't do that. + */ + if (!(pm->old->node.flags & PM_RESTRICTED)) + pm->gsu.i->setfn(pm, 0); break; case PM_EFLOAT: case PM_FFLOAT: -- cgit 1.4.1