From: Kamil Dudka <kdudka@redhat.com>
To: zsh-workers@zsh.org
Subject: [PATCH] parse: fix signed overflow in ecstrcode()
Date: Thu, 14 Mar 2019 10:40:27 +0100 [thread overview]
Message-ID: <20190314094027.13069-1-kdudka@redhat.com> (raw)
Detected by GCC with -fsanitize=undefined:
parse.c:420:47: runtime error: signed integer overflow: -2003020233 - 1064446834 cannot be represented in type 'int'
---
Src/parse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/parse.c b/Src/parse.c
index 83383f10c..22e553a16 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -414,10 +414,10 @@ ecstrcode(char *s)
return c;
} else {
Eccstr p, *pp;
- int cmp;
+ long cmp;
for (pp = &ecstrs; (p = *pp); ) {
- if (!(cmp = p->nfunc - ecnfunc) && !(cmp = (((signed)p->hashval) - ((signed)val))) && !(cmp = strcmp(p->str, s))) {
+ if (!(cmp = p->nfunc - ecnfunc) && !(cmp = (((long)p->hashval) - ((long)val))) && !(cmp = strcmp(p->str, s))) {
return p->offs;
}
pp = (cmp < 0 ? &(p->left) : &(p->right));
--
2.17.2
reply other threads:[~2019-03-14 9:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190314094027.13069-1-kdudka@redhat.com \
--to=kdudka@redhat.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).