From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17728 invoked by alias); 3 May 2015 20:36:21 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35021 Received: (qmail 6438 invoked from network); 3 May 2015 20:36:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=9AQNc4cfcwsS7oJ4bbwrUtr3f5JbbUrTN9OKD/IQzz8=; b=R+LHgScNSggrKZt7LXmZAvnQ4qspdIbC6VTINqSsSJ5b7U7yMzs66+rz4VY0hn3Ulu N1sSUoud0QXSE1C5/ok1MTTOFr+t0LL8/+5+rED1bIDaoAyncvoJcj/o+lzgI5cWkJ0H Cs47R5202WbEgq0lTppoKHyK3v4FEtioT8TRqTdrhcuqS+APWIU6um7eJaPlZe45SPOw lhzXY6V3FseLEXJ43JW6x4cAfdlZvx0gmKK6pRUIluGhQ+maJmAIyw0A8IlGmxb028Tl 4jdi2ydAI62cNemtx34dNZ8uo3g6USQ6+cLCfm4SERm7umfNDR1Xx8MG4SAHvQX07bXF maMQ== X-Received: by 10.180.80.38 with SMTP id o6mr13603162wix.80.1430685377597; Sun, 03 May 2015 13:36:17 -0700 (PDT) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: Fix two bugs in typeset_setbase Date: Sun, 3 May 2015 22:36:02 +0200 Message-Id: <1430685362-12270-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: We refused to set the base outside [2,36], but this restriction should only apply to integers (where the base is actually the base). For float values, the precision can be anything. We also failed to actually enforce this limitation in either of these cases, but only printed the error message. We now only update the base if it was valid. --- Src/builtin.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/builtin.c b/Src/builtin.c index 0113757..1243263 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1865,7 +1865,7 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always) if (arg) { char *eptr; - pm->base = (int)zstrtol(arg, &eptr, 10); + int base = (int)zstrtol(arg, &eptr, 10); if (*eptr) { if (on & PM_INTEGER) zwarnnam(name, "bad base value: %s", arg); @@ -1873,11 +1873,12 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always) zwarnnam(name, "bad precision value: %s", arg); return 1; } - if (pm->base < 2 || pm->base > 36) { + if ((on & PM_INTEGER) && (base < 2 || base > 36)) { zwarnnam(name, "invalid base (must be 2 to 36 inclusive): %d", - pm->base); + base); return 1; } + pm->base = base; } else if (always) pm->base = 0; -- 2.4.0