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