zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] parse: fix signed overflow in ecstrcode()
@ 2019-03-14  9:40 Kamil Dudka
  0 siblings, 0 replies; only message in thread
From: Kamil Dudka @ 2019-03-14  9:40 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-14  9:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14  9:40 [PATCH] parse: fix signed overflow in ecstrcode() Kamil Dudka

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).