patches for freebsd packages

Jo Rhett <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.bugs
Message-ID <[email protected]>
I got lucky when a meeting got delayed for an hour today.  Here are  
the packages, which appear to work properly from my 15 minutes of  
testing.

FYI: I'm sure you know already that Eric Searcy is likely a much  
better programmer than I am.  I hope you aren't waiting on me to  
approve anything he sends you.  He's found more bugs in my code than  
vice versa ;-)



--  
Jo Rhett
Net Consonance : consonant endings by net philanthropy, open source  
and other randomness

_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine
cfengine-freebsd-packages.patch (application/octet-stream, 1.4 KB)
--- package.c_orig	Wed Mar 19 15:31:29 2008
+++ package.c	Wed Mar 19 15:33:28 2008
@@ -1986,14 +1986,17 @@
   char pkgname[CF_BUFSIZE];
   char *pkgversion;
 
-/* The package to install must contain a version number
+/* The package to compare must contain a version number
  * The version starts after the last '-' in the pkgname
  */
 
 strncpy(pkgname, package, CF_BUFSIZE - 1);
 pkgversion = strrchr(pkgname, '-');
-*pkgversion = '\0';
-pkgversion += 1;
+if (pkgversion) 
+   {
+   /* insert a null to remove version for comparison */
+   *pkgversion = '\0';
+   }
 
 Debug("FreeBSDPackageCheck(): Requested version %s %s of %s\n", CMPSENSETEXT[cmp],(version[0] ? version : "ANY"), pkgname);
 
@@ -2011,7 +2014,7 @@
 if ((pp = cfpopen (VBUFF, "r")) == NULL)
    {
    CfLog(cferror,"FATAL: Could not execute pkg_info.\n","popen");
-   return 0;
+   return -1;
    }
 
 while (!feof (pp))
@@ -2061,8 +2064,10 @@
 /* The package name is derived by stripping off the version number */
 strncpy(pkgname, package, CF_BUFSIZE - 1);
 pkgversion = strrchr(pkgname, '-');
-*pkgversion = '\0';
-pkgversion += 1;
+if( pkgversion )
+   {
+   *pkgversion = '\0';
+   }
 
 Debug("FreeBSDPackageCheck(): Requested version %s %s of %s\n", CMPSENSETEXT[cmp],(version[0] ? version : "ANY"), pkgname);
 
@@ -2082,7 +2087,7 @@
 if ((pp = cfpopen (VBUFF, "r")) == NULL)
    {
    Verbose ("Could not execute pkg_info.\n");
-   return 0;
+   return -1;
    }
 
 while (!feof (pp))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.