OSSP CVS Repository

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

Check-in Number: 3389
Date: 2003-May-27 15:00:22 (local)
2003-May-27 13:00:22 (UTC)
User:ms
Branch:
Comment: Bugfix eval mode temp file name creation, and scrap the nonportable BSD call to strnstr(3).
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_proc.c      1.37 -> 1.38     1 inserted, 1 deleted
ossp-pkg/rc/rc_script.c      1.23 -> 1.24     11 inserted, 4 deleted

ossp-pkg/rc/rc_proc.c 1.37 -> 1.38

--- rc_proc.c    2003/05/26 16:24:08     1.37
+++ rc_proc.c    2003/05/27 13:00:22     1.38
@@ -251,7 +251,7 @@
         szTmpfile = malloc(nTmpname);
         strcpy(szTmpfile, configGetval(RC_TMP_VAL));
         if (*(szTmpfile + (strlen(szTmpfile) - 1) * sizeof(char)) != '/')
-            *(szTmpfile + (strlen(szTmpfile)) * sizeof(char)) = '/';
+            strcat(szTmpfile, "/");
         strcat(szTmpfile, RC_EVL_TMP);
         mktemp(szTmpfile);
         strcat(szTmpfile, RC_EVL_SUF);


ossp-pkg/rc/rc_script.c 1.23 -> 1.24

--- rc_script.c  2003/05/27 11:56:00     1.23
+++ rc_script.c  2003/05/27 13:00:22     1.24
@@ -125,12 +125,13 @@
     rc_section_t *pSec = NULL;
     char *piLabstart   = NULL;
     int   nLabsize     = NULL;
-    char *piSubtemp    = NULL; /* To find priority and userid in substrings */
-    char *piBlocend    = NULL; /* Misnomer used to control section looping */
+    char *piSubtemp    = NULL; /* To find priority and userid in substrings  */
+    char *piBlocend    = NULL; /* Misnomer used to control section looping   */
     char *piStart      = NULL;
     char *piEnd        = NULL;
     char *piSep        = NULL;
     char *szUser       = NULL;
+    char *szTemp       = NULL; /* Holds temporarily the pri and user strings */
     struct passwd *pPwd = NULL;
     long  nPri         = 0;
     long  nUid         = 0;
@@ -210,7 +211,9 @@
             /* Handle the section priority */
             piStart = piBlocend + *(pnVec + 4);
             piEnd   = piBlocend + *(pnVec + 5);
-            piSubtemp = strnstr(piStart, RC_DEF_PRG, piEnd - piStart);
+            szTemp  = malloc((piEnd - piStart + 1) * sizeof (char));
+            strncpy(szTemp, piStart, piEnd - piStart + 1);
+            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 */
@@ -224,7 +227,7 @@
                 sectionSetpri(pSec, RC_DEF_PRI);
 
             /* Handle the section userid   */
-            piSubtemp = strnstr(piStart, RC_DEF_UIG, piEnd - piStart);
+            piSubtemp = strstr(szTemp, RC_DEF_UIG);
             if (piSubtemp) { /* Userid pattern found */
                 for (nTmp = (int)piSubtemp + strlen(RC_DEF_UIG); \
                     isspace(*(char *)nTmp); nTmp += sizeof (char)); /* Strip */
@@ -259,6 +262,10 @@
             else /* Fallback to default value */
                 sectionSetuid(pSec, RC_DEF_UID);
 
+            /* Cleanup */
+            free(szTemp);
+            szTemp = NULL;
+
             return(pSec); /* Section found, so return the text */
         }
 

CVSTrac 2.0.1