diff --git a/ChangeLog b/ChangeLog index 3eec09b3f..435babab3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/freshclam/manager.c b/freshclam/manager.c index c739a48f2..c0350a629 100644 --- a/freshclam/manager.c +++ b/freshclam/manager.c @@ -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,8 +491,10 @@ 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; + } } } @@ -652,8 +655,10 @@ 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 */ + } } } @@ -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;