From owner-svn-src-all@freebsd.org Tue May 24 18:49:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E3ADB497AD; Tue, 24 May 2016 18:49:45 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-ig0-f179.google.com (mail-ig0-f179.google.com [209.85.213.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3436717CE; Tue, 24 May 2016 18:49:44 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-ig0-f179.google.com with SMTP id bi2so57965970igb.0; Tue, 24 May 2016 11:49:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc; bh=XyybUbjp4dexNyh6is6Ftv5tPWL03EjGdDel4+jumV0=; b=fsfqYL0IYycHxV/iA8BYhy3ZwkeR1Iy4nHmkGAo0R++AhALMlXeKzC5FpRC5F1HhV4 WETOA7+PduIidFvElbzOZHC/H+u6f+OEws3TPX2lcRm4UMe/3l+Rdbm8ZI98Ubt47Rvb /wT02AAmQAlwKwHx/o3vy65N6vIT3GV1sNPDUOWERUc4zSSRoNlGbvSTXR54VBJPoWfL 1AnXRBHML552h/5OripwhdJt3EvQ6ye1ELPHNNXdXNOp5IddUeXRjdBCE5sdnEeQVgp4 gI5vUMkxjCBt71kd/AgymauzafzjZp60SU2aO3nYeGnghjgAv62yrRI+unaE+S5ISxTD 2ejA== X-Gm-Message-State: ALyK8tLemVHCPBAUAMpdv6hoEJE+NgQPJ04eoarSEBWpbNP53PybRoN2hU5D2+vp0Cr6mA== X-Received: by 10.50.108.109 with SMTP id hj13mr270106igb.96.1464115778627; Tue, 24 May 2016 11:49:38 -0700 (PDT) Received: from mail-ig0-f178.google.com (mail-ig0-f178.google.com. [209.85.213.178]) by smtp.gmail.com with ESMTPSA id u67sm1538142itd.1.2016.05.24.11.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 May 2016 11:49:38 -0700 (PDT) Received: by mail-ig0-f178.google.com with SMTP id l10so16056764igk.0; Tue, 24 May 2016 11:49:37 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.29.72 with SMTP id i8mr3489704igh.48.1464115777783; Tue, 24 May 2016 11:49:37 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.36.205.70 with HTTP; Tue, 24 May 2016 11:49:37 -0700 (PDT) In-Reply-To: <201605241844.u4OIioBp090457@repo.freebsd.org> References: <201605241844.u4OIioBp090457@repo.freebsd.org> Date: Tue, 24 May 2016 11:49:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r300620 - head/lib/libc/rpc From: Conrad Meyer To: Garrett Cooper Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 18:49:45 -0000 On Tue, May 24, 2016 at 11:44 AM, Garrett Cooper 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