Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH 4/5] Src/module: fix use-after-free in setmathfuncs()
- X-seq: zsh-workers 43795
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Kamil Dudka <kdudka@xxxxxxxxxx>
- Subject: Re: [PATCH 4/5] Src/module: fix use-after-free in setmathfuncs()
- Date: Wed, 7 Nov 2018 15:21:31 +0100
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VMaknuHPcioT3keoNs/Gdnr9q3zj9UJem4qx+bj9/vU=; b=qPSq84teIM4UPQkW9URptwud0TPHqqvi3EYIk5snR+FDviQ9nRBpiIUCSU25b7MhNd 8hy3xUR73x0hvyrWDAnNZ/q9s+TKF2SURt7DbwhbnhioZgCPeKuC8sYnLKx2Rw2NmuGF /9dTQh5wca3TMKhsNqS7dKBMZMDAEAYi3prxLtSo0aikr6eBO1nz/IPqatY+fdDFJXTr rRpnp3Cja6NVSZoGyiv4yAEEqY/B5BFnnvTX9/dWFIrgcJLGZ5Ptja9zqrRVfy6519fH OXwkxmfVlloHs2N2rR3RIsJuu4cle1FdNcwhDHBM0z2XF5zEoH3MCAT25lDhD8KG5oCG vOVA==
- In-reply-to: <20181107130456.18901-4-kdudka@redhat.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: <20181107130456.18901-1-kdudka@redhat.com> <20181107130456.18901-4-kdudka@redhat.com>
On 11/7/18, Kamil Dudka <kdudka@xxxxxxxxxx> wrote:
> Detected by Coverity Analysis:
>
> Error: USE_AFTER_FREE (CWE-825):
> zsh-5.5.1/Src/module.c:1390: freed_arg: "deletemathfunc" frees "f".
> zsh-5.5.1/Src/module.c:1352:6: freed_arg: "zfree" frees parameter "f".
> zsh-5.5.1/Src/mem.c:1888:5: freed_arg: "free" frees parameter "p".
> zsh-5.5.1/Src/module.c:1394: deref_after_free: Dereferencing freed pointer
> "f".
> 1392| ret = 1;
> 1393| } else {
> 1394|-> f->flags &= ~MFF_ADDED;
> 1395| }
> 1396| }
> ---
> Src/module.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/Src/module.c b/Src/module.c
> index 4ae78310f..33d75ebbd 100644
> --- a/Src/module.c
> +++ b/Src/module.c
> @@ -1390,8 +1390,6 @@ setmathfuncs(char const *nam, MathFunc f, int size,
> int *e)
> if (deletemathfunc(f)) {
> zwarnnam(nam, "math function `%s' already deleted", f->name);
> ret = 1;
> - } else {
> - f->flags &= ~MFF_ADDED;
> }
> }
> f++;
> --
> 2.17.2
In the other branch, if f was already deleted, how can we use f->name there?
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author