freshclam/manager.c: fix error path memleaks - bb#1141

git-svn: trunk@4126
0.95
Tomasz Kojm 17 years ago
parent d706617ce5
commit 1246054902
  1. 4
      ChangeLog
  2. 21
      freshclam/manager.c

@ -1,3 +1,7 @@
Thu Aug 21 13:29:22 CEST 2008 (tk)
----------------------------------
* freshclam/manager.c: fix error path memleaks - bb#1141
Thu Aug 21 13:24:17 CEST 2008 (tk)
----------------------------------
* shared/tar.c: fix invalid close on error path - bb#1141

@ -459,6 +459,7 @@ static char *proxyauth(const char *user, const char *pass)
buf[len] = '\0';
auth = malloc(strlen(buf) + 30);
if(!auth) {
free(buf);
logg("!proxyauth: Can't allocate memory for 'authorization'\n");
return NULL;
}
@ -490,10 +491,12 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
if(user) {
authorization = proxyauth(user, pass);
if(!authorization)
if(!authorization) {
free(remotename);
return NULL;
}
}
}
if(stat(file, &sb) != -1 && sb.st_mtime < time(NULL)) {
Rfc2822DateTime(last_modified, sb.st_mtime);
@ -652,10 +655,12 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
if(user) {
authorization = proxyauth(user, pass);
if(!authorization)
if(!authorization) {
free(remotename);
return 75; /* FIXME */
}
}
}
if(uas)
strncpy(uastr, uas, sizeof(uastr));
@ -673,6 +678,12 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
"Connection: close\r\n"
"\r\n", (remotename != NULL) ? remotename : "", srcfile, hostname, (authorization != NULL) ? authorization : "", uastr);
if(remotename)
free(remotename);
if(authorization)
free(authorization);
memset(ipaddr, 0, sizeof(ipaddr));
if(ip[0]) /* use ip to connect */
sd = wwwconnect(ip, proxy, port, ipaddr, localip, ctimeout, mdat, logerr, can_whitelist);
@ -694,12 +705,6 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
return 52;
}
if(remotename)
free(remotename);
if(authorization)
free(authorization);
/* read http headers */
ch = buffer;
i = 0;

Loading…
Cancel
Save