Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: #6 negative job id (Re: Zsh - Multiple DoS Vulnerabilities)
- X-seq: zsh-workers 44290
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: David Wells <bughunters@xxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: PATCH: #6 negative job id (Re: Zsh - Multiple DoS Vulnerabilities)
- Date: Mon, 13 May 2019 23:11:13 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1557781875; bh=7SgJjdt5HvROV/9hLEMxAwXSj+2Cf2x6Fzl5ZPDgKt4=; h=From:References:To:Subject:Date:From:Subject; b=lue7ggRG930uI3SIzTCngxMbMeH+fJ5B7aUcMGV0eYnK/k9t8dnnHluLQrPA53hhYOEK+kfq+T0BboYsNamJGQ+xTjpk5U7HnY+BNEPB+O+GMvTfMOXSOsCWln2uTjQ6DDNG/cI8N1t1aNDDAmx5oRyVG2lsHImBWvMvi2C0CYX7MWvahMaHOfwmB1uc+A4+sfBc+7Q5SedkA+bes6dwea4a1HIgH10oBx7W4ZgiZgzH04tCbo5rxMXmAHOlhFgjEIzP0URwoDTIfNUUhAWEGZHedzRnzgwEUjlXhC9yd2R25f0zSbb268hGgE0L15nAbDIZwbBmi3ti+zz8/aZgFw==
- In-reply-to: <CAH+w=7Y8d0h43rM_dHhbiT8nvL3-zxF8DUWTjn--hPX8sF7iaA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAAOKOsfSAR5aRBvEcyQKRzDCvOgRJdyRvVb9AXMq6d22RaUozQ@mail.gmail.com> <CAH+w=7Y8d0h43rM_dHhbiT8nvL3-zxF8DUWTjn--hPX8sF7iaA@mail.gmail.com>
On 10 May, Bart wrote:
> > #6 Invalid read from *getjob *in *jobs.c*
> > POC folder: *06_getjob_(jobs.c_1935)*
>
> This one I fed to "zsh -xf" and got (file name removed for readability):
>
> +1> bg $'%\M-\C-?' $'\C-VI7'
> bg:1: no job control in this shell.
> +1> disown $'%777777777777777\M-^'
This can be reproduced with just %777777777777777
or %2147483648 for that matter. Seems the value returned from atoi()
wraps to negative values if it doesn't fit in an int.
This patch prevents the crash but perhaps atoi() should be replaced with
something that does better error handling to cover numbers that are too
big but get truncated to something positive.
Oliver
diff --git a/Src/jobs.c b/Src/jobs.c
index 73d7f26da..50751decb 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1932,7 +1932,7 @@ getjob(const char *s, const char *prog)
/* a digit here means we have a job number */
if (idigit(*s)) {
jobnum = atoi(s);
- if (jobnum && jobnum <= mymaxjob && myjobtab[jobnum].stat &&
+ if (jobnum > 0 && jobnum <= mymaxjob && myjobtab[jobnum].stat &&
!(myjobtab[jobnum].stat & STAT_SUBJOB) &&
/*
* If running jobs in a subshell, we are allowed to
Messages sorted by:
Reverse Date,
Date,
Thread,
Author