OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_file.c versions 1.5 and 1.6
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc_file.c 1.5 -> 1.6

--- rc_file.c    2003/07/07 12:55:42     1.5
+++ rc_file.c    2003/07/08 15:09:50     1.6
@@ -86,7 +86,9 @@
     if (!configGetval(RC_LOC_VAL))  /* Config should have */
         RC_THROW(RC_ERR_INT);       /* given a locs default */
     else { /* Only enter block with valid string, strdup can't handle NULL */
-        if (*(configGetval(RC_LOC_VAL) + strlen(configGetval(RC_LOC_VAL)) - sizeof (char)) != '/') {
+        /* FIXME mlelstv -- crashes on zero-length RC_LOC_VAL string */
+        if (*(configGetval(RC_LOC_VAL) + strlen(configGetval(RC_LOC_VAL)) - 1) != '/') {
+            /* FIXME mlelstv -- void pointer arithmetic from hell */
             szLocex = malloc(strlen(configGetval(RC_LOC_VAL)) + \
                              sizeof (char) + \
                              strlen("rc.") + \
@@ -118,6 +120,7 @@
     while ((nRet = read(nFdrc, sBuf, RC_READ_BUFSIZE)) > 0)
         scriptnAppend(pScript, sBuf, nRet);
 
+    /* FIXME mlelstv -- errno is lost ? */
     if (nRet == -1) /* Handle read errors */
         RC_THROW(RC_ERR_IO);
 
@@ -139,6 +142,7 @@
         long nUid          = 0;
         int nUserbytes     = 0;
         int nTmp           = 0;
+        char *pTmp         = NULL;
         int nOffset        = 0;
         int nFound         = 0;
         int nVecsize       = 0;
@@ -160,8 +164,10 @@
             RC_THROW(RC_ERR_SYS);
         }
 
-        if (pcre_fullinfo(pRegex, pExtra, PCRE_INFO_CAPTURECOUNT, &nSubstrings))
+        if (pcre_fullinfo(pRegex, pExtra, PCRE_INFO_CAPTURECOUNT, &nSubstrings)) {
+            free(pRegex);
             RC_THROW(RC_ERR_SYS);
+        }
 
         /***********************************************************************/
         /* Reminder: PCRE writes vectors to help identify substrings.          */
@@ -198,7 +204,7 @@
             piEnd     = piBlocend + *(pnVec + 7);
             szName = malloc((nLabsize + 1) * sizeof (char));
             strncpy(szName, piSecname, nLabsize);
-            *(szName + nLabsize * sizeof (char)) = '\0';
+            *(szName + nLabsize) = '\0';
             pSec = sectionNew(szName);
             free(szName);   /* Get rid of the temporary, actually   */
             szName = NULL;  /* just for making a new section string */
@@ -217,10 +223,11 @@
             *(szTemp + nPribytes) = '\0';
             piSubtemp = strstr(szTemp, RC_DEF_PRG);
             if (piSubtemp) { /* Priority pattern found */
-                for (nTmp = (int)piSubtemp + strlen(RC_DEF_PRG); \
-                    isspace(*(char *)nTmp); nTmp += sizeof (char)); /* Strip */
-                nPri = strtol((char *)nTmp, &piSep, 10);
-                if ((char *)nTmp == piSep)  /* No priority number follows */
+                for (pTmp = piSubtemp + strlen(RC_DEF_PRG); \
+                    isspace(*pTmp); pTmp += 1)
+                    continue; /* Strip */
+                nPri = strtol(pTmp, &piSep, 10);
+                if (pTmp == piSep)          /* No priority number follows */
                     RC_THROW(RC_ERR_USE);   /* which is an error */
                 else
                     sectionSetpri(pSec, nPri);  /* Found a priority value */
@@ -289,11 +296,14 @@
                 strlen(piBlocend), 0, 0, pnVec, nVecsize);
         }
 
-    /* Handle errors */
-    if (nFound == 1)                        /* User gave no klammern */
-        RC_THROW(RC_ERR_USE);               /* so complain about it */
-    else if (nFound < PCRE_ERROR_NOMATCH)   /* Generic problem so */
-        RC_THROW(RC_ERR_SYS);               /* return an error */
+        /* release compiled regex */
+        free(pRegex);
+
+        /* Handle errors */
+        if (nFound == 1)                        /* User gave no klammern */
+            RC_THROW(RC_ERR_USE);               /* so complain about it */
+        else if (nFound < PCRE_ERROR_NOMATCH)   /* Generic problem so */
+            RC_THROW(RC_ERR_SYS);               /* return an error */
     }
 
     /* Deallocate and clean */

CVSTrac 2.0.1