Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 May 2016 11:49:37 -0700
From:      Conrad Meyer <cem@FreeBSD.org>
To:        Garrett Cooper <ngie@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r300620 - head/lib/libc/rpc
Message-ID:  <CAG6CVpUYMpc_Bj4cnNVqi9Yoaq0PTowjmM6brpeV8ZjrsHbe2w@mail.gmail.com>
In-Reply-To: <201605241844.u4OIioBp090457@repo.freebsd.org>
References:  <201605241844.u4OIioBp090457@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 24, 2016 at 11:44 AM, Garrett Cooper <ngie@freebsd.org> wrote:
> Author: ngie
> Date: Tue May 24 18:44:50 2016
> New Revision: 300620
> URL: https://svnweb.freebsd.org/changeset/base/300620
>
> Log:
>   Use reallocf instead of malloc to fix leak with outbuf_pmap
>
> ...
>
>   Add a outbuf_pmap = NULL in the failure case to avoid a double-free
>   at the bottom of the function.
>
> ...
> Modified: head/lib/libc/rpc/clnt_bcast.c
> ==============================================================================
> --- head/lib/libc/rpc/clnt_bcast.c      Tue May 24 17:38:27 2016        (r300619)
> +++ head/lib/libc/rpc/clnt_bcast.c      Tue May 24 18:44:50 2016        (r300620)
> @@ -346,7 +346,9 @@ rpc_broadcast_exp(rpcprog_t prog, rpcver
>  #ifdef PORTMAP
>                 if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) {
>                         udpbufsz = fdlist[fdlistno].dsize;
> -                       if ((outbuf_pmap = malloc(udpbufsz)) == NULL) {
> +                       outbuf_pmap = reallocf(outbuf_pmap, udpbufsz);
> +                       if (outbuf_pmap == NULL) {
> +                               outbuf_pmap = NULL;

Huh?  This seems a little redundant.

>                                 _close(fd);
>                                 stat = RPC_SYSTEMERROR;
>                                 goto done_broad;
>

Best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpUYMpc_Bj4cnNVqi9Yoaq0PTowjmM6brpeV8ZjrsHbe2w>