OSSP CVS Repository

ossp - Check-in [3500]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3500
Date: 2003-Jul-08 17:09:50 (local)
2003-Jul-08 15:09:50 (UTC)
User:mlelstv
Branch:
Comment: flush audit comments and changes
Tickets:
Inspections:
Files:
ossp-pkg/rc/configure.in      1.20 -> 1.21     8 inserted, 8 deleted
ossp-pkg/rc/devtool.conf      1.15 -> 1.16     19 inserted, 12 deleted
ossp-pkg/rc/rc_error.c      1.9 -> 1.10     2 inserted, 0 deleted
ossp-pkg/rc/rc_file.c      1.5 -> 1.6     22 inserted, 12 deleted
ossp-pkg/rc/rc_list.c      1.5 -> 1.6     16 inserted, 6 deleted
ossp-pkg/rc/rc_opt.c      1.9 -> 1.10     10 inserted, 12 deleted
ossp-pkg/rc/rc_proc.c      1.60 -> 1.61     7 inserted, 2 deleted
ossp-pkg/rc/rc_sect.c      1.19 -> 1.20     38 inserted, 32 deleted

ossp-pkg/rc/configure.in 1.20 -> 1.21

--- configure.in 2003/07/07 13:30:51     1.20
+++ configure.in 2003/07/08 15:09:50     1.21
@@ -72,10 +72,10 @@
 AC_CHECK_EXTLIB([OSSP popt],
                 popt, popt_getcontext, popt.h,
                 [SUBDIR_POPT=""],
-                [SUBDIR_POPT="rc_popt"
-                 CPPFLAGS="$CPPFLAGS -Irc_popt"
-                 CFLAGS="$CFLAGS -Irc_popt"
-                 LDFLAGS="$LDFLAGS -Lrc_popt/.libs"
+                [SUBDIR_POPT="lib_popt"
+                 CPPFLAGS="$CPPFLAGS -Ilib_popt"
+                 CFLAGS="$CFLAGS -Ilib_popt"
+                 LDFLAGS="$LDFLAGS -Llib_popt/.libs"
                  LIBS_EXTRA="$LIBS_EXTRA -lpopt"])
 AC_SUBST(SUBDIR_POPT)
 
@@ -83,10 +83,10 @@
 AC_CHECK_EXTLIB([OSSP ex],
                 ex, __ex_ctx, ex.h,
                 [SUBDIR_EX=""],
-                [SUBDIR_EX="rc_ex"
-                 CPPFLAGS="$CPPFLAGS -Irc_ex"
-                 CFLAGS="$CFLAGS -Irc_ex"
-                 LDFLAGS="$LDFLAGS -Lrc_ex/.libs"
+                [SUBDIR_EX="lib_ex"
+                 CPPFLAGS="$CPPFLAGS -Ilib_ex"
+                 CFLAGS="$CFLAGS -Ilib_ex"
+                 LDFLAGS="$LDFLAGS -Llib_ex/.libs"
                  LIBS_EXTRA="$LIBS_EXTRA -lex"])
 AC_SUBST(SUBDIR_EX)
 


ossp-pkg/rc/devtool.conf 1.15 -> 1.16

--- devtool.conf 2003/07/07 15:19:26     1.15
+++ devtool.conf 2003/07/08 15:09:50     1.16
@@ -2,16 +2,23 @@
 ##  devtool.conf -- Development Tool Configuration
 ##
 
+%checkout
+    for name in ex popt; do
+        echo "===> lib_${name} (cvs co)"
+        cvs co -d lib_${name} ${name}
+        echo "<=== lib_${name}"
+    done
+
 %autogen
     @autogen shtool   1.6.2 "1.[56].*" all
     @autogen autoconf 2.57  "2.5[3-9]*"
 
-    echo "===> rc_ex (devtool autogen)"
-    (cd rc_ex && ./devtool autogen)
-    echo "<=== rc_ex"
-    echo "===> rc_popt (devtool autogen)"
-    (cd rc_popt && ./devtool autogen)
-    echo "<=== rc_popt"
+    echo "===> lib_ex (devtool autogen)"
+    (cd lib_ex && ./devtool autogen)
+    echo "<=== lib_ex"
+    echo "===> lib_popt (devtool autogen)"
+    (cd lib_popt && ./devtool autogen)
+    echo "<=== lib_popt"
 #    echo "===> rc_str (devtool autogen)"
 #    (cd rc_str && ./devtool autogen)
 #    echo "<=== rc_str"
@@ -26,12 +33,12 @@
     @autoclean shtool
     @autoclean autoconf
 
-    echo "===> rc_ex (devtool autoclean)"
-    (cd rc_ex && ./devtool autoclean)
-    echo "<=== rc_ex"
-    echo "===> rc_popt (devtool autoclean)"
-    (cd rc_popt && ./devtool autoclean)
-    echo "<=== rc_popt"
+    echo "===> lib_ex (devtool autoclean)"
+    (cd lib_ex && ./devtool autoclean)
+    echo "<=== lib_ex"
+    echo "===> lib_popt (devtool autoclean)"
+    (cd lib_popt && ./devtool autoclean)
+    echo "<=== lib_popt"
 #    echo "===> rc_str (devtool autoclean)"
 #    (cd rc_str && ./devtool autoclean)
 #    echo "<=== rc_str"


ossp-pkg/rc/rc_error.c 1.9 -> 1.10

--- rc_error.c   2003/07/07 13:30:51     1.9
+++ rc_error.c   2003/07/08 15:09:50     1.10
@@ -38,6 +38,8 @@
 ************************************************/
 void rcError(ex_t Localerr)
 {
+    /* FIXME mlelstv -- looks like a case for a switch (pun intended) */
+
     if (FAILED((rc_return_t)Localerr.ex_value)) { /* Error condition */
         if ((rc_return_t)Localerr.ex_value == RC_ERR_TRM)
             exit(0);


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 */


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

--- rc_list.c    2003/07/07 13:30:51     1.5
+++ rc_list.c    2003/07/08 15:09:50     1.6
@@ -63,8 +63,11 @@
     if (!kszName)
         return(RC_THROW(RC_ERR_RCF));
     else { /* Only enter block with valid string, strdup can't handle NULL */
+        /* FIXME mlelstv -- why malloc only a single pointer ? */
+        /* FIXME mlelstv -- why malloc when non-wildcard case allocs itself ? */
         pInst->m_ppFilevec = malloc(sizeof (rc_file_t *));
         if (strcmp(kszName, RC_GLOB_WILD)) {
+            /* FIXME mlelstv -- already using two pointes here */
             pInst->m_ppFilevec[0] = rcfileNew(kszName);  /* For an object  */
             pInst->m_ppFilevec[1] = rcfileNew(NULL);     /* For the tail   */
             pInst->m_nFiles = 1;             /* We handle just one rc file */
@@ -110,9 +113,13 @@
                 if (nCount == 0) /* Check out the health of this directory listing */
                     return(RC_THROW(RC_ERR_LOC));
                 nIter = 0; /* Used in the next for block, so initialize */
+                /* FIXME mlelstv -- overwriting m_ppFilevec ?? */
                 pInst->m_ppFilevec = calloc(nCount + 1, sizeof (rc_file_t *));
                 if (!pInst->m_ppFilevec) /* Guard against memory overruns */
                     return(RC_THROW(RC_ERR_MEM));
+                /* FIXME mlelstv -- scanning directory twice, so being unsure
+                 *                  about how many files we have
+                 */
                 if ((pLocdir = opendir(szLocations)) == NULL)
                     return(RC_THROW(RC_ERR_LOC));
 
@@ -149,12 +156,13 @@
     assert(pInst && kszName); /* Dummy check */
 
     /* Iterate through list, searching for a rcfile matching the given name */
-    for (nIter = 0; nIter < pInst->m_nFiles && \
-        strcmp(pInst->m_ppFilevec[nIter]->m_szName, kszName); nIter++);
-    if (nIter < pInst->m_nFiles)
-        return(pInst->m_ppFilevec[nIter]);  /* Name of rcfile in list matched */
-    else
-        return(NULL);                       /* Name did not match any rcfile  */
+    for (nIter = 0; nIter < pInst->m_nFiles; nIter++) {
+        if (strcmp(pInst->m_ppFilevec[nIter]->m_szName, kszName) == 0)
+            /* Name of rcfile in list matched */
+            return(pInst->m_ppFilevec[nIter]);
+    }
+
+    return(NULL);  /* Name did not match any rcfile  */
 }
 
 /************************************************
@@ -171,8 +179,10 @@
     assert(pInst);  /* Verify sanity */
 
     if (pInst->m_ppFilevec) {
+        /* free all rcfiles including extra tail element */
         for (nIter = 0; nIter <= pInst->m_nFiles; nIter++) {
             if (pInst->m_ppFilevec[nIter]) {
+                /* FIXME mlelstv -- should be rcfileDelete() */
                 free(pInst->m_ppFilevec[nIter]); /* Deallocate a rcfile */
                 pInst->m_ppFilevec[nIter] = NULL;
             }


ossp-pkg/rc/rc_opt.c 1.9 -> 1.10

--- rc_opt.c     2003/07/07 13:30:51     1.9
+++ rc_opt.c     2003/07/08 15:09:50     1.10
@@ -33,6 +33,7 @@
 
 #include "rc.h"
 
+/* FIXME mlelstv -- why Construct/Destruct vs. New/Delete ? */
 
 /***************************************
 * optConstruct(rc_opt_t **)            *
@@ -58,6 +59,7 @@
 rc_return_t optGetname(rc_opt_t *pOption, char **pszName)
 {
     assert(pOption && pOption->szName);
+    /* FIXME mlelstv -- why non-shared read ? */
     if (!(*pszName = strdup(pOption->szName)))  /* Get name from option     */
         return(RC_THROW(RC_ERR_MEM));
     else
@@ -67,6 +69,7 @@
 rc_return_t optGetval(rc_opt_t *pOption, char **pszVal)
 {
     assert(pOption && pOption->szVal);
+    /* FIXME mlelstv -- why non-shared read ? */
     if (!(*pszVal = strdup(pOption->szVal)))    /* Get value from option    */
         return(RC_THROW(RC_ERR_MEM));
     else
@@ -103,19 +106,14 @@
 ***************************************/
 rc_return_t optDestruct(rc_opt_t **ppOption)
 {
-    ex_t Except;
+    assert(*ppOption);              /* Error if not constructed */
 
-    assert(*ppOption);                  /* Error if not constructed */
-    try {
-        if ((*ppOption)->szName)        /* Might not be mallocd yet */
-            free((*ppOption)->szName);
-        if ((*ppOption)->szVal)         /* Might not be mallocd yet */
-            free((*ppOption)->szVal);
-        free(*ppOption);                /* Deallocate option and    */
-        *ppOption = NULL;               /* clear its reference      */
-    }
-    catch(Except)
-        rethrow;
+    if ((*ppOption)->szName)        /* Might not be mallocd yet */
+        free((*ppOption)->szName);
+    if ((*ppOption)->szVal)         /* Might not be mallocd yet */
+        free((*ppOption)->szVal);
+    free(*ppOption);                /* Deallocate option and    */
+    *ppOption = NULL;               /* clear its reference      */
 
     return(RC_THROW(RC_OK));
 }


ossp-pkg/rc/rc_proc.c 1.60 -> 1.61

--- rc_proc.c    2003/07/07 13:30:51     1.60
+++ rc_proc.c    2003/07/08 15:09:50     1.61
@@ -91,7 +91,7 @@
                 scriptnAppend(pRc->m_pScriptfunc, sBuf, nRet);
             if (nRet == -1) /* Handle read errors */
                 RC_THROW(RC_ERR_IO);
-            scriptnAppend(pRc->m_pScriptfunc, "\n", sizeof("\n"));
+            scriptnAppend(pRc->m_pScriptfunc, "\n", strlen("\n"));
             close(nFdfunc); /* Close Func file handle */
         }
         else
@@ -133,7 +133,8 @@
         catch(Except)
             rethrow;
 
-        /* Attach our rcfile in the list */
+        /* Replace rcfile in the list with combined sections */
+        rcfileDelete(pRc->m_pList->m_ppFilevec[nRcs]);
         pRc->m_pList->m_ppFilevec[nRcs] = pRcfile;
         pRcfile = NULL;
     }
@@ -156,6 +157,10 @@
 *******************************************/
 rc_return_t procRun(rc_proc_t *pRc)
 {
+    /* FIXME mlelstv - mode switch should be an enum
+     *                 set to one of the four modes
+     *                 and be tested with a switch()
+     */
     if (configGetval(RC_EVL_VAL))       /* Evaluate */
         return(procEval(pRc));
     else if (configGetval(RC_EXC_VAL))  /* Execute */


ossp-pkg/rc/rc_sect.c 1.19 -> 1.20

--- rc_sect.c    2003/07/07 13:30:51     1.19
+++ rc_sect.c    2003/07/08 15:09:50     1.20
@@ -46,15 +46,13 @@
     /* Among other things, they make great coffee at Cable & Wireless */
     /* This code would probably have more bugs if the coffee was not as good */
     pSec = (rc_section_t *)calloc(1, sizeof(rc_section_t));
-
-    if (pSec) {
-        pSec->m_szName = malloc((strlen(szName) + 1) * sizeof(char));
-        strcpy(pSec->m_szName, szName);
-        pSec->m_pData = scriptNew();
-    }
-    else
+    if (pSec == NULL)
         RC_THROW(RC_ERR_MEM);
 
+    pSec->m_szName = malloc((strlen(szName) + 1) * sizeof(char));
+    strcpy(pSec->m_szName, szName);
+    pSec->m_pData = scriptNew();
+
     return(pSec);
 }
 
@@ -73,21 +71,21 @@
 
     /* Deep copy of section name */
     if (pOrigsec->m_szName) {
-        pSec->m_szName = malloc((strlen(pOrigsec->m_szName) + sizeof(char))\
+        pSec->m_szName = malloc((strlen(pOrigsec->m_szName) + 1)\
             * sizeof(char));
         strcpy(pSec->m_szName, pOrigsec->m_szName);
     }
 
     /* Deep copy of parent name */
     if (pOrigsec->m_szParent) {
-        pSec->m_szParent = malloc((strlen(pOrigsec->m_szParent) + sizeof(char))\
+        pSec->m_szParent = malloc((strlen(pOrigsec->m_szParent) + 1)\
             * sizeof(char));
         strcpy(pSec->m_szParent, pOrigsec->m_szParent);
     }
 
     /* Deep copy of user name */
     if (pOrigsec->m_szLogin) {
-        pSec->m_szLogin = malloc((strlen(pOrigsec->m_szLogin) + sizeof(char))\
+        pSec->m_szLogin = malloc((strlen(pOrigsec->m_szLogin) + 1)\
             * sizeof(char));
         strcpy(pSec->m_szLogin, pOrigsec->m_szLogin);
     }
@@ -171,8 +169,10 @@
 
 const char *sectionGetdata(rc_section_t *pSec)
 { /* Data of section, this is the script body of the particular section */
+  /* ATTENTION: data section may be NULL */
     if (pSec) {
         const char *kszScriptdata = scriptGetdata(pSec->m_pData);
+        /* FIXME mlelstv -- why is an empty section NULL ? */
         if (kszScriptdata && strlen(kszScriptdata) > 0)
             return(kszScriptdata);
         else
@@ -248,7 +248,7 @@
 
     if (scriptGetdata(pSec->m_pData)) { /* The section data is already in use */
         scriptDelete(pSec->m_pData);
-        pSec->m_pData = NULL;
+        pSec->m_pData = scriptNew();
     }
 
     scriptSetdata(pSec->m_pData, kszIn);
@@ -261,17 +261,14 @@
     char *szTemp  = NULL;
     size_t nBytes = (Len + 1) * sizeof(char);       /* Set size */
 
-    assert(pSec && kszIn); /* Dummy detector */
-
-    if (pSec->m_pData) {    /* The section data is already in use */
-        scriptDelete(pSec->m_pData);
-    }
-
-    pSec->m_pData = scriptNew();
+    /* copy data with terminating NUL character */
     szTemp = malloc(nBytes);
     strncpy(szTemp, kszIn, Len);
     *(szTemp + Len) = '\0';                 /* Terminate outgoing */
-    scriptSetdata(pSec->m_pData, szTemp);   /* Finish the job */
+
+    /* FIXME mlelstv -- how to do exception handling ?? */
+    sectionSetdata(pSec, szTemp);           /* Finish the job */
+
     free(szTemp);                           /* Deallocate */
     szTemp = NULL;
     return(RC_THROW(RC_OK));
@@ -301,23 +298,32 @@
 ************************************************/
 rc_return_t sectionWrite(rc_section_t *pSec, const char *szPath)
 {
-    int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
+    int nFdtmp = -1;
     FILE *pStream = NULL;
 
-    /* Initial sanity checks */
-    if (!pSec || nFdtmp < 0)
+    /* Parameter sanity checks */
+    if (!pSec)
         return(RC_THROW(RC_ERR_USE));
-    else
-        pStream = fdopen(nFdtmp, "w");
 
-    if (pStream) {
-        fprintf(pStream, "#su %s\n", sectionGetlogin(pSec));
-        fprintf(pStream, "%s", sectionGetdata(pSec));
-        fclose(pStream);
-        return(RC_THROW(RC_OK));
-    }
-    else
+    /* open file with restricted mode 0600 to preserve privacy */
+    nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
+    if (nFdtmp < 0)
+        return(RC_THROW(RC_ERR_USE));
+
+    pStream = fdopen(nFdtmp, "w");
+    if (pStream == NULL) {
+        close(nFdtmp);
+        unlink(szPath);
         return(RC_THROW(RC_ERR_USE));
+    }
+
+    fprintf(pStream, "#su %s\n", sectionGetlogin(pSec));
+    fprintf(pStream, "%s", sectionGetdata(pSec));
+    fclose(pStream);
+
+    /* this file is deleted by user, no cleanup necessary */
+
+    return(RC_THROW(RC_OK));
 }
 
 /************************************************
@@ -343,7 +349,7 @@
         free(pSec);
     }
     else    /* Dumbass passed an empty section object */
-        assert(FALSE);
+        return(RC_THROW(RC_ERR_USE));
 
     return(RC_THROW(RC_OK));
 }

CVSTrac 2.0.1