RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/lib/ psm.c

From: Ralf S. Engelschall <rse@rpm5.org>
Date: Thu 19 Jul 2007 - 08:14:54 CEST
Message-Id: <20070719061454.9F0383484F5@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Ralf S. Engelschall
  Root:   /v/rpm/cvs                       Email:  rse@rpm5.org
  Module: rpm                              Date:   19-Jul-2007 08:14:54
  Branch: HEAD                             Handle: 2007071907145400

  Modified files:
    rpm/lib                 psm.c

  Log:
    Plug a memory leak and/or avoid segfaults by freeing the correct buffer
    as dirname(3) on some platforms return a pointer to internal storage
    space allocated on the first call that will be overwritten by subsequent
    calls while on other platforms it may just modify the contents of the
    string passed to it in-place.

  Summary:
    Revision    Changes     Path
    2.210       +4  -2      rpm/lib/psm.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/lib/psm.c
  ============================================================================
  $ cvs diff -u -r2.209 -r2.210 psm.c
  --- rpm/lib/psm.c	18 Jul 2007 12:56:03 -0000	2.209
  +++ rpm/lib/psm.c	19 Jul 2007 06:14:54 -0000	2.210
  @@ -1682,6 +1682,7 @@
   	    /* Open output package for writing. */
   	    {	char tiddn[32];
   		const char * bfmt;
  +		const char * pkgdn_buf;
   		const char * pkgdn;
   		const char * pkgbn;
   
  @@ -1695,9 +1696,10 @@
   					pkgbn);
   		pkgbn = _free(pkgbn);
   		(void) urlPath(psm->pkgURL, &psm->pkgfn);
  -		pkgdn = dirname(xstrdup(psm->pkgfn));
  +		pkgdn_buf = xstrdup(psm->pkgfn);
  +		pkgdn = dirname(pkgdn_buf);
   		rc = rpmMkdirPath(pkgdn, "_repackage_dir");
  -		pkgdn = _free(pkgdn);
  +		pkgdn_buf = _free(pkgdn_buf);
   		if (rc == RPMRC_FAIL)
   		    break;
   		psm->fd = Fopen(psm->pkgfn, "w.fdio");
  @@ .
Received on Thu Jul 19 08:14:54 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.