Blame SOURCES/coverity.patch

31807d
diff -up ./include/be.h.coverity ./include/be.h
31807d
--- ./include/be.h.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./include/be.h	2018-10-10 19:27:18.680632681 +0200
31807d
@@ -22,6 +22,6 @@
31807d
 #define _BE_H_INCLUDED
31807d
 #include "db_config.h"
31807d
 
31807d
-FILE* be_init(int inout,url_t* u,int iszipped);
31807d
+void* be_init(int inout,url_t* u,int iszipped);
31807d
 
31807d
 #endif /* _BE_H_INCLUDED */
31807d
diff -up ./include/db_config.h.coverity ./include/db_config.h
31807d
--- ./include/db_config.h.coverity	2018-10-10 19:27:18.672632611 +0200
31807d
+++ ./include/db_config.h	2018-10-10 19:27:18.681632689 +0200
31807d
@@ -376,7 +376,7 @@ typedef struct db_config {
31807d
 #endif
31807d
 
31807d
   url_t* initial_report_url;
31807d
-  FILE* initial_report_fd;
31807d
+  void* initial_report_fd;
31807d
   
31807d
   /* report_url is a list of url_t*s */
31807d
   list* report_url;
31807d
diff -up ./src/aide.c.coverity ./src/aide.c
31807d
--- ./src/aide.c.coverity	2018-10-10 19:27:18.678632663 +0200
31807d
+++ ./src/aide.c	2018-10-10 19:27:18.681632689 +0200
31807d
@@ -278,7 +278,7 @@ static void setdefaults_before_config()
31807d
     error(0,_("Couldn't get hostname"));
31807d
     free(s);
31807d
   } else {
31807d
-    s=(char*)realloc((void*)s,strlen(s)+1);
31807d
+  //  s=(char*)realloc((void*)s,strlen(s)+1);
31807d
     do_define("HOSTNAME",s);
31807d
   }
31807d
   
31807d
@@ -506,8 +506,6 @@ static void setdefaults_after_config()
31807d
 int main(int argc,char**argv)
31807d
 {
31807d
   int errorno=0;
31807d
-  byte* dig=NULL;
31807d
-  char* digstr=NULL;
31807d
 
31807d
 #ifdef USE_LOCALE
31807d
   setlocale(LC_ALL,"");
31807d
@@ -544,6 +542,10 @@ int main(int argc,char**argv)
31807d
   }
31807d
   
31807d
   errorno=commandconf('C',conf->config_file);
31807d
+  if (errorno==RETFAIL){
31807d
+    error(0,_("Configuration error\n"));
31807d
+    exit(INVALID_CONFIGURELINE_ERROR);
31807d
+  }
31807d
 
31807d
   errorno=commandconf('D',"");
31807d
   if (errorno==RETFAIL){
31807d
@@ -594,6 +596,9 @@ int main(int argc,char**argv)
31807d
       }
31807d
   }
31807d
 #ifdef WITH_MHASH
31807d
+  byte* dig=NULL;
31807d
+  char* digstr=NULL;
31807d
+
31807d
   if(conf->config_check&&FORCECONFIGMD){
31807d
     error(0,"Can't give config checksum when compiled with --enable-forced_configmd\n");
31807d
     exit(INVALID_ARGUMENT_ERROR);
31807d
diff -up ./src/base64.c.coverity ./src/base64.c
31807d
--- ./src/base64.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/base64.c	2018-10-10 19:27:18.681632689 +0200
31807d
@@ -209,6 +209,7 @@ byte* decode_base64(char* src,size_t ssi
31807d
 	case FAIL:
31807d
 	  error(3, "decode_base64: Illegal character: %c\n", *inb);
31807d
 	  error(230, "decode_base64: Illegal line:\n%s\n", src);
31807d
+	  free(outbuf);
31807d
 	  return NULL;
31807d
 	  break;
31807d
 	case SKIP:
31807d
@@ -260,7 +261,7 @@ size_t length_base64(char* src,size_t ss
31807d
   int l;
31807d
   int left;
31807d
   size_t pos;
31807d
-  unsigned long triple;
31807d
+  //unsigned long triple;
31807d
 
31807d
   error(235, "decode base64\n");
31807d
   /* Exit on empty input */
31807d
@@ -273,7 +274,7 @@ size_t length_base64(char* src,size_t ss
31807d
   inb = src;
31807d
 
31807d
   l = 0;
31807d
-  triple = 0;
31807d
+  //triple = 0;
31807d
   pos=0;
31807d
   left = ssize;
31807d
   /*
31807d
@@ -293,7 +294,7 @@ size_t length_base64(char* src,size_t ss
31807d
 	case SKIP:
31807d
 	  break;
31807d
 	default:
31807d
-	  triple = triple<<6 | (0x3f & i);
31807d
+	  //triple = triple<<6 | (0x3f & i);
31807d
 	  l++;
31807d
 	  break;
31807d
 	}
31807d
@@ -302,10 +303,10 @@ size_t length_base64(char* src,size_t ss
31807d
 	  switch(l)
31807d
 	    {
31807d
 	    case 2:
31807d
-	      triple = triple>>4;
31807d
+	      //triple = triple>>4;
31807d
 	      break;
31807d
 	    case 3:
31807d
-	      triple = triple>>2;
31807d
+	      //triple = triple>>2;
31807d
 	      break;
31807d
 	    default:
31807d
 	      break;
31807d
@@ -314,7 +315,7 @@ size_t length_base64(char* src,size_t ss
31807d
 	    {
31807d
 	      pos++;
31807d
 	    }
31807d
-	  triple = 0;
31807d
+	  //triple = 0;
31807d
 	  l = 0;
31807d
 	}
31807d
       inb++;
31807d
diff -up ./src/be.c.coverity ./src/be.c
31807d
--- ./src/be.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/be.c	2018-10-10 19:27:18.681632689 +0200
31807d
@@ -117,9 +117,9 @@ static char* get_first_value(char** in){
31807d
 
31807d
 #endif
31807d
 
31807d
-FILE* be_init(int inout,url_t* u,int iszipped)
31807d
+void* be_init(int inout,url_t* u,int iszipped)
31807d
 {
31807d
-  FILE* fh=NULL;
31807d
+  void* fh=NULL;
31807d
   long a=0;
31807d
   char* err=NULL;
31807d
   int fd;
31807d
diff -up ./src/commandconf.c.coverity ./src/commandconf.c
31807d
--- ./src/commandconf.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/commandconf.c	2018-10-10 19:27:18.682632698 +0200
31807d
@@ -106,7 +106,7 @@ int commandconf(const char mode,const ch
31807d
       rv=0;
31807d
     } else {
31807d
       
31807d
-      rv=access(config,R_OK);
31807d
+      if (config != NULL) rv=access(config,R_OK);
31807d
       if(rv==-1){
31807d
 	error(0,_("Cannot access config file: %s: %s\n"),config,strerror(errno));
31807d
       }
31807d
@@ -166,14 +166,11 @@ int commandconf(const char mode,const ch
31807d
 int conf_input_wrapper(char* buf, int max_size, FILE* in)
31807d
 {
31807d
   int retval=0;
31807d
-  int c=0;
31807d
-  char* tmp=NULL;
31807d
-  void* key=NULL;
31807d
-  int keylen=0;
31807d
 
31807d
   /* FIXME Add support for gzipped config. :) */
31807d
 #ifdef WITH_MHASH
31807d
   /* Read a character at a time until we are doing md */
31807d
+  int c=0;
31807d
   if(conf->do_configmd){
31807d
     retval=fread(buf,1,max_size,in);
31807d
   }else {
31807d
@@ -185,6 +182,9 @@ int conf_input_wrapper(char* buf, int ma
31807d
 #endif 
31807d
 
31807d
 #ifdef WITH_MHASH    
31807d
+  char* tmp=NULL;
31807d
+  void* key=NULL;
31807d
+  int keylen=0;
31807d
   if(conf->do_configmd||conf->config_check){
31807d
     if(((conf->do_configmd==1)&&conf->config_check)||!conf->confmd){
31807d
       if(conf->do_configmd==1){
31807d
@@ -276,6 +276,9 @@ int db_input_wrapper(char* buf, int max_
31807d
 #endif
31807d
     break;
31807d
   }
31807d
+  default: {
31807d
+    return 0;
31807d
+  }
31807d
   }
31807d
 
31807d
 #ifdef WITH_CURL
31807d
@@ -651,7 +654,6 @@ int handle_endif(int doit,int allow_else
31807d
       case 0 : {
31807d
 	conferror("@@endif or @@else expected");
31807d
 	return -1;
31807d
-	count=0;
31807d
       }
31807d
       
31807d
       default : {
31807d
@@ -816,6 +818,7 @@ void do_dbdef(int dbtype,char* val)
31807d
       if(u==NULL||u->type==url_unknown||u->type==url_stdout
31807d
 	 ||u->type==url_stderr) {
31807d
 	error(0,_("Unsupported input URL-type:%s\n"),val);
31807d
+	free(u);
31807d
       }
31807d
       else {
31807d
 	*conf_db_url=u;
31807d
@@ -825,6 +828,7 @@ void do_dbdef(int dbtype,char* val)
31807d
     case DB_WRITE: {
31807d
       if(u==NULL||u->type==url_unknown||u->type==url_stdin){
31807d
 	error(0,_("Unsupported output URL-type:%s\n"),val);
31807d
+	free(u);
31807d
       }
31807d
       else{
31807d
 	conf->db_out_url=u;
31807d
@@ -848,6 +852,7 @@ void do_dbindef(char* val)
31807d
     if(u==NULL||u->type==url_unknown||u->type==url_stdout
31807d
        ||u->type==url_stderr) {
31807d
       error(0,_("Unsupported input URL-type:%s\n"),val);
31807d
+      free(u);
31807d
     }
31807d
     else {
31807d
       conf->db_in_url=u;
31807d
@@ -869,6 +874,7 @@ void do_dboutdef(char* val)
31807d
      * both input and output urls */
31807d
     if(u==NULL||u->type==url_unknown||u->type==url_stdin){
31807d
       error(0,_("Unsupported output URL-type:%s\n"),val);
31807d
+      free(u);
31807d
     }
31807d
     else{
31807d
       conf->db_out_url=u;
31807d
@@ -894,7 +900,8 @@ void do_repurldef(char* val)
31807d
   } else {
31807d
     error_init(u,0);
31807d
   }
31807d
-  
31807d
+
31807d
+  free(u);  
31807d
 }
31807d
 
31807d
 void do_verbdef(char* val)
31807d
@@ -984,7 +991,7 @@ void do_report_ignore_e2fsattrs(char* va
31807d
                  break;
31807d
             }
31807d
         }
31807d
-        *val++;
31807d
+        (*val)++;
31807d
     }
31807d
 }
31807d
 #endif
31807d
diff -up ./src/compare_db.c.coverity ./src/compare_db.c
31807d
--- ./src/compare_db.c.coverity	2018-10-10 19:27:18.673632619 +0200
31807d
+++ ./src/compare_db.c	2018-10-10 19:27:18.682632698 +0200
31807d
@@ -312,7 +312,7 @@ static int acl2array(acl_type* acl, char
31807d
         if (conf->syslog_format) {
31807d
             *values = malloc(2 * sizeof(char*));
31807d
 
31807d
-            char *A, *D = "<none>";
31807d
+            char *A= "<none>", *D = "<none>";
31807d
 
31807d
             if (acl->acl_a) { A = acl->acl_a; } 
31807d
             if (acl->acl_d) { D = acl->acl_d; } 
31807d
diff -up ./src/conf_lex.l.coverity ./src/conf_lex.l
31807d
--- ./src/conf_lex.l.coverity	2018-10-10 19:27:18.673632619 +0200
31807d
+++ ./src/conf_lex.l	2018-10-10 19:27:18.682632698 +0200
31807d
@@ -133,7 +133,7 @@ int var_in_conflval=0;
31807d
 <expr>[\ \t]*\n {
31807d
   conf_lineno++;
31807d
   return (TNEWLINE);
31807d
-  BEGIN 0;
31807d
+//  BEGIN 0;
31807d
 }
31807d
 
31807d
 <expr>\+ {
31807d
diff -up ./src/db.c.coverity ./src/db.c
31807d
--- ./src/db.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/db.c	2018-10-10 19:27:18.683632707 +0200
31807d
@@ -27,6 +27,7 @@
31807d
 #include "db_file.h"
31807d
 #include "db_disk.h"
31807d
 #include "md.h"
31807d
+#include "fopen.h"
31807d
 
31807d
 #ifdef WITH_PSQL
31807d
 #include "db_sql.h"
31807d
@@ -269,6 +270,9 @@ db_line* db_readline(int db){
31807d
     db_order=&(conf->db_new_order);
31807d
     break;
31807d
   }
31807d
+  default: {
31807d
+    return NULL;
31807d
+  }
31807d
   }
31807d
 
31807d
   switch (db_url->type) {
31807d
@@ -368,7 +372,7 @@ db_line* db_char2line(char** ss,int db){
31807d
 
31807d
   int i;
31807d
   db_line* line=(db_line*)malloc(sizeof(db_line)*1);
31807d
-  int* db_osize=0;
31807d
+  int* db_osize=NULL;
31807d
   DB_FIELD** db_order=NULL;
31807d
 
31807d
   switch (db) {
31807d
@@ -382,6 +386,10 @@ db_line* db_char2line(char** ss,int db){
31807d
     db_order=&(conf->db_new_order);
31807d
     break;
31807d
   }
31807d
+  default: {
31807d
+    free(line);
31807d
+    return NULL;
31807d
+  }
31807d
   }
31807d
 
31807d
 
31807d
@@ -601,7 +609,9 @@ db_line* db_char2line(char** ss,int db){
31807d
             size_t vsz = 0;
31807d
             
31807d
             tval = strtok(NULL, ",");
31807d
-            line->xattrs->ents[num].key = db_readchar(strdup(tval));
31807d
+            char * tmp = strdup(tval);
31807d
+            line->xattrs->ents[num].key = db_readchar(tmp);
31807d
+            free(tmp);
31807d
             tval = strtok(NULL, ",");
31807d
             val = base64tobyte(tval, strlen(tval), &vsz);
31807d
             line->xattrs->ents[num].val = val;
31807d
@@ -648,6 +658,8 @@ db_line* db_char2line(char** ss,int db){
31807d
     
31807d
     default : {
31807d
       error(0,_("Not implemented in db_char2line %i \n"),(*db_order)[i]);
31807d
+      free_db_line(line);
31807d
+      free(line);
31807d
       return NULL;
31807d
     }
31807d
     
31807d
@@ -826,7 +838,7 @@ void db_close() {
31807d
   case url_ftp:
31807d
     {
31807d
         if (conf->db_out!=NULL) {
31807d
-            url_fclose(conf->db_out);
31807d
+            url_fclose((URL_FILE*)conf->db_out);
31807d
         }
31807d
       break;
31807d
     }
31807d
diff -up ./src/db_disk.c.coverity ./src/db_disk.c
31807d
--- ./src/db_disk.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/db_disk.c	2018-10-10 19:28:00.108995089 +0200
31807d
@@ -79,9 +79,15 @@ static DIR *open_dir(char* path) {
31807d
 
31807d
 static void next_in_dir (void)
31807d
 {
31807d
+
31807d
 #ifdef HAVE_READDIR_R
31807d
-	if (dirh != NULL)
31807d
+	if (dirh != NULL) {
31807d
+#pragma GCC diagnostic push
31807d
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
31807d
 		rdres = AIDE_READDIR_R_FUNC (dirh, entp, resp);
31807d
+#pragma GCC diagnostic pop
31807d
+    }
31807d
+
31807d
 #else
31807d
 #ifdef HAVE_READDIR
31807d
 	if (dirh != NULL) {
31807d
diff -up ./src/db_file.c.coverity ./src/db_file.c
31807d
--- ./src/db_file.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/db_file.c	2018-10-10 19:27:18.683632707 +0200
31807d
@@ -171,7 +171,7 @@ int dofprintf( const char* s,...)
31807d
 int db_file_read_spec(int db){
31807d
   
31807d
   int i=0;
31807d
-  int* db_osize=0;
31807d
+  int* db_osize=NULL;
31807d
   DB_FIELD** db_order=NULL;
31807d
 
31807d
   switch (db) {
31807d
@@ -187,6 +187,9 @@ int db_file_read_spec(int db){
31807d
     db_lineno=&db_new_lineno;
31807d
     break;
31807d
   }
31807d
+  default: {
31807d
+    return RETFAIL;
31807d
+  }
31807d
   }
31807d
 
31807d
   *db_order=(DB_FIELD*) malloc(1*sizeof(DB_FIELD));
31807d
@@ -198,13 +201,10 @@ int db_file_read_spec(int db){
31807d
       int l;
31807d
       
31807d
 
31807d
-      /* Yes... we do not check if realloc returns nonnull */
31807d
-
31807d
-      *db_order=(DB_FIELD*)
31807d
-	realloc((void*)*db_order,
31807d
+       void * tmp = realloc((void*)*db_order,
31807d
 		((*db_osize)+1)*sizeof(DB_FIELD));
31807d
-      
31807d
-      if(*db_order==NULL){
31807d
+      if (tmp != NULL) *db_order=(DB_FIELD*) tmp;
31807d
+      else {
31807d
 	return RETFAIL;
31807d
       }
31807d
       
31807d
@@ -291,8 +291,8 @@ char** db_readline_file(int db){
31807d
   int* domd=NULL;
31807d
 #ifdef WITH_MHASH
31807d
   MHASH* md=NULL;
31807d
-#endif
31807d
   char** oldmdstr=NULL;
31807d
+#endif
31807d
   int* db_osize=0;
31807d
   DB_FIELD** db_order=NULL;
31807d
   FILE** db_filep=NULL;
31807d
@@ -302,9 +302,9 @@ char** db_readline_file(int db){
31807d
   case DB_OLD: {
31807d
 #ifdef WITH_MHASH
31807d
     md=&(conf->dboldmd);
31807d
+    oldmdstr=&(conf->old_dboldmdstr);
31807d
 #endif
31807d
     domd=&(conf->do_dboldmd);
31807d
-    oldmdstr=&(conf->old_dboldmdstr);
31807d
     
31807d
     db_osize=&(conf->db_in_size);
31807d
     db_order=&(conf->db_in_order);
31807d
@@ -316,9 +316,9 @@ char** db_readline_file(int db){
31807d
   case DB_NEW: {
31807d
 #ifdef WITH_MHASH
31807d
     md=&(conf->dbnewmd);
31807d
+    oldmdstr=&(conf->old_dbnewmdstr);
31807d
 #endif
31807d
     domd=&(conf->do_dbnewmd);
31807d
-    oldmdstr=&(conf->old_dbnewmdstr);
31807d
     
31807d
     db_osize=&(conf->db_new_size);
31807d
     db_order=&(conf->db_new_order);
31807d
@@ -328,7 +328,9 @@ char** db_readline_file(int db){
31807d
     break;
31807d
   }
31807d
   }
31807d
-  
31807d
+
31807d
+  if (db_osize == NULL) return NULL;
31807d
+
31807d
   if (*db_osize==0) {
31807d
     db_buff(db,*db_filep);
31807d
     
31807d
@@ -737,8 +739,6 @@ int db_writespec_file(db_config* dbconf)
31807d
   int i=0;
31807d
   int j=0;
31807d
   int retval=1;
31807d
-  void*key=NULL;
31807d
-  int keylen=0;
31807d
   struct tm* st;
31807d
   time_t tim=time(&tim);
31807d
   st=localtime(&tim);
31807d
@@ -750,6 +750,8 @@ int db_writespec_file(db_config* dbconf)
31807d
 
31807d
 #ifdef WITH_MHASH
31807d
   /* From hereon everything must MD'd before write to db */
31807d
+  void*key=NULL;
31807d
+  int keylen=0;
31807d
   if((key=get_db_key())!=NULL){
31807d
     keylen=get_db_key_len();
31807d
     dbconf->do_dbnewmd=1;
31807d
diff -up ./src/do_md.c.coverity ./src/do_md.c
31807d
--- ./src/do_md.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/do_md.c	2018-10-10 19:27:18.683632707 +0200
31807d
@@ -202,7 +202,6 @@ void calc_md(struct AIDE_STAT_TYPE* old_
31807d
     and we don't read from a pipe :)
31807d
    */
31807d
   struct AIDE_STAT_TYPE fs;
31807d
-  int sres=0;
31807d
   int stat_diff,filedes;
31807d
 #ifdef WITH_PRELINK
31807d
   pid_t pid;
31807d
@@ -237,7 +236,7 @@ void calc_md(struct AIDE_STAT_TYPE* old_
31807d
     return;
31807d
   }
31807d
   
31807d
-  sres=AIDE_FSTAT_FUNC(filedes,&fs);
31807d
+  AIDE_FSTAT_FUNC(filedes,&fs);
31807d
   if(!(line->attr&DB_RDEV))
31807d
 	  fs.st_rdev=0;
31807d
   
31807d
@@ -331,7 +330,7 @@ void calc_md(struct AIDE_STAT_TYPE* old_
31807d
       }
31807d
 #endif
31807d
 #endif /* not HAVE_MMAP */
31807d
-      buf=malloc(READ_BLOCK_SIZE);
31807d
+//      buf=malloc(READ_BLOCK_SIZE);
31807d
 #if READ_BLOCK_SIZE>SSIZE_MAX
31807d
 #error "READ_BLOCK_SIZE" is too large. Max value is SSIZE_MAX, and current is READ_BLOCK_SIZE
31807d
 #endif
31807d
diff -up ./src/gen_list.c.coverity ./src/gen_list.c
31807d
--- ./src/gen_list.c.coverity	2016-07-25 22:56:55.000000000 +0200
31807d
+++ ./src/gen_list.c	2018-10-10 19:27:18.684632716 +0200
31807d
@@ -843,15 +843,15 @@ static void add_file_to_tree(seltree* tr
31807d
   DB_ATTR_TYPE localignorelist=0;
31807d
   DB_ATTR_TYPE ignored_added_attrs, ignored_removed_attrs, ignored_changed_attrs;
31807d
 
31807d
+  if(file==NULL){
31807d
+    error(0, "add_file_to_tree was called with NULL db_line\n");
31807d
+  }
31807d
+
31807d
   node=get_seltree_node(tree,file->filename);
31807d
 
31807d
   if(!node){
31807d
     node=new_seltree_node(tree,file->filename,0,NULL);
31807d
   }
31807d
-  
31807d
-  if(file==NULL){
31807d
-    error(0, "add_file_to_tree was called with NULL db_line\n");
31807d
-  }
31807d
 
31807d
   /* add note to this node which db has modified it */
31807d
   node->checked|=db;
31807d
diff -up ./src/md.c.coverity ./src/md.c
31807d
--- ./src/md.c.coverity	2018-10-10 19:27:18.679632672 +0200
31807d
+++ ./src/md.c	2018-10-10 19:27:18.684632716 +0200
31807d
@@ -36,8 +36,8 @@
31807d
 */
31807d
 
31807d
 DB_ATTR_TYPE hash_gcrypt2attr(int i) {
31807d
-  DB_ATTR_TYPE r=0;
31807d
 #ifdef WITH_GCRYPT
31807d
+  DB_ATTR_TYPE r=0;
31807d
   switch (i) {
31807d
   case GCRY_MD_MD5: {
31807d
     r=DB_MD5;
31807d
@@ -74,13 +74,15 @@ DB_ATTR_TYPE hash_gcrypt2attr(int i) {
31807d
   default:
31807d
     break;
31807d
   }
31807d
-#endif
31807d
   return r;
31807d
+#else /* !WITH_GCRYPT */
31807d
+  return 0;
31807d
+#endif
31807d
 }
31807d
 
31807d
 const char * hash_gcrypt2str(int i) {
31807d
-  char * r = "?";
31807d
 #ifdef WITH_GCRYPT
31807d
+  char * r = "?";
31807d
   switch (i) {
31807d
   case GCRY_MD_MD5: {
31807d
     r = "MD5";
31807d
@@ -117,13 +119,17 @@ const char * hash_gcrypt2str(int i) {
31807d
   default:
31807d
     break;
31807d
   }
31807d
-#endif
31807d
   return r;
31807d
+#else /* !WITH_GCRYPT */
31807d
+  return "?";
31807d
+#endif
31807d
 }
31807d
 
31807d
+#pragma GCC diagnostic push
31807d
+#pragma GCC diagnostic ignored "-Wunused-parameter"
31807d
 DB_ATTR_TYPE hash_mhash2attr(int i) {
31807d
-  DB_ATTR_TYPE r=0;
31807d
 #ifdef WITH_MHASH
31807d
+  DB_ATTR_TYPE r=0;
31807d
   switch (i) {
31807d
   case MHASH_CRC32: {
31807d
     r=DB_CRC32;
31807d
@@ -198,10 +204,15 @@ DB_ATTR_TYPE hash_mhash2attr(int i) {
31807d
   default:
31807d
     break;
31807d
   }
31807d
-#endif
31807d
+
31807d
   return r;
31807d
+#else /*!WITH_MHASH */
31807d
+  return 0;
31807d
+#endif
31807d
 }
31807d
 
31807d
+#pragma GCC diagnostic pop
31807d
+
31807d
 /*
31807d
   Initialise md_container according it's todo_attr field
31807d
  */
31807d
@@ -317,7 +328,6 @@ int init_md(struct md_container* md) {
31807d
  */
31807d
 
31807d
 int update_md(struct md_container* md,void* data,ssize_t size) {
31807d
-  int i;
31807d
     
31807d
   error(255,"update_md called\n");
31807d
 
31807d
@@ -328,6 +338,7 @@ int update_md(struct md_container* md,vo
31807d
 #endif
31807d
 
31807d
 #ifdef WITH_MHASH
31807d
+  int i;
31807d
   
31807d
   for(i=0;i<=HASH_MHASH_COUNT;i++) {
31807d
     if (md->mhash_mdh[i]!=MHASH_FAILED) {
31807d
@@ -348,7 +359,6 @@ int update_md(struct md_container* md,vo
31807d
 */
31807d
 
31807d
 int close_md(struct md_container* md) {
31807d
-  int i;
31807d
 #ifdef _PARAMETER_CHECK_
31807d
   if (md==NULL) {
31807d
     return RETFAIL;
31807d
@@ -356,6 +366,7 @@ int close_md(struct md_container* md) {
31807d
 #endif
31807d
   error(255,"close_md called \n");
31807d
 #ifdef WITH_MHASH
31807d
+  int i;
31807d
   for(i=0;i<=HASH_MHASH_COUNT;i++) {
31807d
     if (md->mhash_mdh[i]!=MHASH_FAILED) {
31807d
       mhash (md->mhash_mdh[i], NULL, 0);
31807d
diff -up ./src/util.c.coverity ./src/util.c
31807d
--- ./src/util.c.coverity	2018-10-10 19:27:18.670632593 +0200
31807d
+++ ./src/util.c	2018-10-10 19:27:18.684632716 +0200
31807d
@@ -105,13 +105,15 @@ url_t* parse_url(char* val)
31807d
       for(i=0;r[0]!='/'&&r[0]!='\0';r++,i++);
31807d
       if(r[0]=='\0'){
31807d
 	error(0,"Invalid file-URL,no path after hostname: file:%s\n",t);
31807d
+        free(hostname);
31807d
 	return NULL;
31807d
       }
31807d
       u->value=strdup(r);
31807d
       r[0]='\0';
31807d
       if(gethostname(hostname,MAXHOSTNAMELEN)==-1){
31807d
-    strncpy(hostname,"localhost", 10);
31807d
+        strncpy(hostname,"localhost", 10);
31807d
       }
31807d
+
31807d
       if( (strcmp(t,"localhost")==0)||(strcmp(t,hostname)==0)){
31807d
 	free(hostname);
31807d
 	break;
31807d
@@ -120,7 +122,7 @@ url_t* parse_url(char* val)
31807d
 	free(hostname);
31807d
 	return NULL;
31807d
       }
31807d
-      free(hostname);
31807d
+
31807d
       break;
31807d
     }
31807d
     u->value=strdup(r);