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