Selaa lähdekoodia

Bug 630097 - (cov#11964) Remove dead code from libaccess

The libaccess library has some dead functions it it.  One of these
functions was flagged as having a NULL pointer dereference issue
by Coverity.  The problem function is unused, so it should be removed.
There are also a number of other unused functions in the same source
file that should be removed.
Nathan Kinder 15 vuotta sitten
vanhempi
sitoutus
562f39848c
1 muutettua tiedostoa jossa 0 lisäystä ja 196 poistoa
  1. 0 196
      lib/libaccess/acltools.cpp

+ 0 - 196
lib/libaccess/acltools.cpp

@@ -1509,202 +1509,6 @@ Symbol_t *sym;
     return(ACLERRUNDEF);
 }
 
-/*
- * local function: translate string to lower case
- * return <0: fail
- *        0: succeed
- */
-int 
-open_file_buf(FILE ** file, char * filename, char *mode, char ** buf, long * size)
-{
-	int rv = 0;
-	long cur = 0;
-	long in = 0;
-	struct stat fi;
-
-	if (filename==NULL || mode==NULL) {
-		rv = ACLERROPEN;
-		goto open_cleanup;
-	}
-
-	if ((*file=fopen(filename,mode))==NULL) {
-		rv = ACLERROPEN;
-		goto open_cleanup;
-	}
-
-	if (system_stat(filename, &fi)==-1) {
-		rv = ACLERROPEN;
-		goto open_cleanup;
-	}
-
-	*size = fi.st_size;
-	
-	if ((*buf=(char *)PERM_MALLOC(*size+1))==NULL) {
-		rv = ACLERRNOMEM;
-		goto open_cleanup;
-	}
-
-	
-	rv = 0;
-	while (cur<*size) {
-		in=fread(&(*buf)[cur], 1, *size, *file);
-		cur = cur+in;
-		if (feof(*file)) {
-			break;
-		}
-		if (ferror(*file)) {
-			rv = ACLERRIO;
-			break;
-		}
-	}
-	if (rv==0)
-		(*buf)[cur] = 0;
-
-open_cleanup:
-	if (rv<0) {
-		if (*file)
-			fclose(*file);
-		if (*buf) {
-			PERM_FREE(*buf);
-			*buf = NULL;
-		}
-	}
-	return rv;
-}
-
-
-/*
- * local function: writes buf to disk and close the file
- */
-void 
-close_file_buf(FILE * file, char * filename, char * mode, char * buf) 
-{
-	if (file==NULL)
-		return;
-	fclose(file);
-	if (strchr(mode, 'w')!=NULL || strchr(mode, 'a')!=NULL) {
-		file = fopen(filename, "wb");
-		fwrite(buf,1,strlen(buf),file);  
-		fclose(file);
-	}
-	if (*buf) {
-		PERM_FREE(buf);
-	}
-}
-
-
-/*
- * local function: translate string to lower case
- */
-char *
-str_tolower(char * string)
-{
-	register char * p = string;
-	for (; *p; p++)
-		*p = tolower(*p);
-	return string;
-}
-
-/*
- * local function: get the first name appear in block
- * return: 0 : not found, 
- *         1 : found
- */
-int 
-acl_get_first_name(char * block, char ** name, char ** next) 
-{
-	char bounds[] = "\t \"\';";
-	char boundchar;
-	char *p=NULL, *q=NULL, *start=NULL, *end=NULL;
-
-	if (block==NULL)
-		return 0;
-try_next:
-	if ((p=strstr(block, "acl"))!=NULL) {
-
-		// check if this "acl" is the first occurance in this line.
-		for (q=p-1; ((q>=block) && *q!='\n'); q--) {
-			if (strchr(" \t",*q)==NULL) {
-				// if not, try next;
-				block = p+3;
-				goto try_next;
-			}
-		}
-		
-		p+=3;
-		while (strchr(bounds,*p)&&(*p!=0))
-			p++;
-		if (*p==0)
-			return 0;
-		boundchar = *(p-1);
-		start = p;
-		while ((boundchar!=*p)&&(*p!=0)&&(*p!=';'))
-			p++;
-		if (*p==0)
-			return 0;
-		end = p;
-		*name = (char *)PERM_MALLOC(end-start+1);
-		strncpy(*name, start, (end-start));
-		(*name)[end-start]=0;
-		*next = end;
-		return 1;
-	}
-	return 0;
-}
-
-/*
- * local function: find the pointer to acl string from the given block
- */
-char *
-acl_strstr(char * block, char * aclname) 
-{
-	const char set[] = "\t \"\';";
-	char * name, * rstr = NULL; 
-	char * lowerb = block;
-	int found = 0;
-
-	if (block==NULL||aclname==NULL)
-		return NULL;
-
-	while ((name = strstr(block, aclname))!=NULL && !found) {
-		if (name>lowerb) {	// This should be true, just in case
-			if ((strchr(set,name[-1])!=0) && (strchr(set,name[strlen(aclname)])!=0)) {
-				// the other 2 sides are in boundary set, that means, this is an exact match.
-				while (&name[-1]>=lowerb) {
-					name --;
-					if (strchr(set, *name)==0)
-						break; // should point to 'l'
-				}
-
-				if (name==lowerb)
-					return NULL;
-
-				if ((name-2)>=lowerb) 
-					if ((name[-2]=='a') && (name[-1]=='c') && (*name=='l')) {
-						name -= 2;	// name point to 'a'
-						rstr = name;
-						while (TRUE) {
-							if (name==lowerb) {
-								found = 1;
-								break;
-							}
-							else if (name[-1]==' '||name[-1]=='\t') 
-								name --;
-							else if (name[-1]=='\n') {
-								found = 1;
-								break;
-							}
-							else 
-								break; // acl is not at the head, there are other chars.
-						}
-					}
-			}
-			block = name + strlen(aclname);
-		}
-	}
-	return rstr;
-}
-
 
 /*
  * Destroy a NameList