summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-09-13 14:56:16 -0700
committerNathan Kinder <nkinder@redhat.com>2010-09-15 09:11:05 -0700
commit562f39848cdb2486d97cc730607337f7bd5e566c (patch)
treeaec5e9f54a48556550a73ab9680db1469fcb663c /lib
parent7c00bf728c3a8c20c08d76f66cccaf892c81a5f2 (diff)
downloadds-562f39848cdb2486d97cc730607337f7bd5e566c.tar.gz
ds-562f39848cdb2486d97cc730607337f7bd5e566c.tar.xz
ds-562f39848cdb2486d97cc730607337f7bd5e566c.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/libaccess/acltools.cpp196
1 files changed, 0 insertions, 196 deletions
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
index 4e1274e2..69d0c2e2 100644
--- a/lib/libaccess/acltools.cpp
+++ b/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