pcp
[Top] [All Lists]

Re: [pcp] PCP bugs from SGI

To: Martin Hicks <mort@xxxxxxx>
Subject: Re: [pcp] PCP bugs from SGI
From: Martin Hicks <mort@xxxxxxxx>
Date: Mon, 15 Mar 2010 08:59:41 -0400
Cc: pcp@xxxxxxxxxxx
In-reply-to: <20100311180034.GH17944@xxxxxxxxxxxxxxxxxxxxxxxxx>
References: <20100311180034.GH17944@xxxxxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Thu, Mar 11, 2010 at 12:00:34PM -0600, Martin Hicks wrote:
> 
> Hi,
> 
> I finally went through the PCP queue at SGI and cleaned out a pile of
> old bugs.  I found a number that were potentially interesting projects
> for some aspiring PCP developer, so I pushed these into bugzilla.
> 
> There were also some bugs related to core functionality in PCP that was
> questionable in regards to error checking.  I opened one in particular: 
> 

Here is the fix for another such PV that was inside SGI, related to
AddBadHost():


mort@laplace:~/src/pcp$ git show HEAD
commit a5c4f1f1197a5b7238a9eb3f3fccad1ea1d7a390
Author: Martin Hicks <mort@xxxxxxxx>
Date:   Thu Mar 11 11:45:03 2010 -0500

    Use realloc in AddBadHost
    
    Otherwise existing client info will be lost during the malloc.

diff --git a/src/pmcd/src/pmcd.c b/src/pmcd/src/pmcd.c
index 00c7976..5f1d32c 100644
--- a/src/pmcd/src/pmcd.c
+++ b/src/pmcd/src/pmcd.c
@@ -1166,7 +1166,7 @@ AddBadHost(struct in_addr *hostId)
     if (nBadHosts == szBadHosts) {
        szBadHosts += 8;
        need = szBadHosts * (int)sizeof(badHost[0]);
-       if ((badHost = (struct in_addr *)malloc(need)) == NULL) {
+       if ((badHost = (struct in_addr *)realloc(badHost, need)) == NULL) {
            __pmNoMem("pmcd.AddBadHost", need, PM_FATAL_ERR);
        }
     }
mort@laplace:~/src/pcp$ git show HEAD
commit a5c4f1f1197a5b7238a9eb3f3fccad1ea1d7a390
Author: Martin Hicks <mort@xxxxxxxx>
Date:   Thu Mar 11 11:45:03 2010 -0500

    Use realloc in AddBadHost
    
    Otherwise existing client info will be lost during the malloc.

diff --git a/src/pmcd/src/pmcd.c b/src/pmcd/src/pmcd.c
index 00c7976..5f1d32c 100644
--- a/src/pmcd/src/pmcd.c
+++ b/src/pmcd/src/pmcd.c
@@ -1166,7 +1166,7 @@ AddBadHost(struct in_addr *hostId)
     if (nBadHosts == szBadHosts) {
        szBadHosts += 8;
        need = szBadHosts * (int)sizeof(badHost[0]);
-       if ((badHost = (struct in_addr *)malloc(need)) == NULL) {
+       if ((badHost = (struct in_addr *)realloc(badHost, need)) == NULL) {
            __pmNoMem("pmcd.AddBadHost", need, PM_FATAL_ERR);
        }
     }


<Prev in Thread] Current Thread [Next in Thread>