Przeglądaj źródła

plugins/check_apt.c - Print uninitialized ereg

Coverity 66531 - ereg.buffer can be printed without being initialized if do_include and do_exclude are null and critical is an invalid regex. While minor this may leak memory and cause undefined behavior.
Spenser Reinhardt 11 lat temu
rodzic
commit
28be924428
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      plugins/check_apt.c

+ 3 - 0
plugins/check_apt.c

@@ -223,6 +223,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
 	regex_t ireg, ereg, sreg;
 	char *cmdline=NULL, rerrbuf[64];
 
+	/* initialize ereg as it is possible it is printed while uninitialized */
+	memset(&ereg, "\0", sizeof(ereg.buffer));
+
 	if(upgrade==NO_UPGRADE) return STATE_OK;
 
 	/* compile the regexps */