... | ... |
@@ -96,6 +96,8 @@ clamd_connect (const char *cfgfile, const char *option) |
96 | 96 |
return -11; |
97 | 97 |
} |
98 | 98 |
|
99 |
+ return sockd; |
|
100 |
+ |
|
99 | 101 |
} |
100 | 102 |
else |
101 | 103 |
#endif |
... | ... |
@@ -143,6 +145,7 @@ clamd_connect (const char *cfgfile, const char *option) |
143 | 143 |
|
144 | 144 |
optfree(opts); |
145 | 145 |
freeaddrinfo(res); |
146 |
+ |
|
146 | 147 |
return sockd; |
147 | 148 |
} |
148 | 149 |
|
... | ... |
@@ -190,8 +193,8 @@ clamd_connect (const char *cfgfile, const char *option) |
190 | 190 |
return -1; |
191 | 191 |
} |
192 | 192 |
|
193 |
+ return sockd; |
|
193 | 194 |
#endif |
194 |
- |
|
195 | 195 |
} |
196 | 196 |
else |
197 | 197 |
{ |
... | ... |
@@ -202,7 +205,7 @@ clamd_connect (const char *cfgfile, const char *option) |
202 | 202 |
} |
203 | 203 |
|
204 | 204 |
optfree (opts); |
205 |
- return sockd; |
|
205 |
+ return -1; |
|
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
int |
... | ... |
@@ -229,7 +232,7 @@ notify (const char *cfgfile) |
229 | 229 |
{ |
230 | 230 |
logg ("!NotifyClamd: Unknown answer from clamd: '%s'\n", buff); |
231 | 231 |
closesocket (sockd); |
232 |
- return 1; |
|
232 |
+ return -1; |
|
233 | 233 |
} |
234 | 234 |
} |
235 | 235 |
|
... | ... |
@@ -202,8 +202,6 @@ struct device *get_devices(void) |
202 | 202 |
} |
203 | 203 |
#endif |
204 | 204 |
|
205 |
- close(sock); |
|
206 |
- |
|
207 | 205 |
p = realloc(devices, sizeof(struct device) * (ndevices + 1)); |
208 | 206 |
if (!(p)) |
209 | 207 |
goto err; |
... | ... |
@@ -215,9 +213,6 @@ struct device *get_devices(void) |
215 | 215 |
return devices; |
216 | 216 |
|
217 | 217 |
err: |
218 |
- if (addrs) |
|
219 |
- freeifaddrs(addrs); |
|
220 |
- |
|
221 | 218 |
if (devices) { |
222 | 219 |
for (i=0; i < ndevices; i++) |
223 | 220 |
if (devices[i].name) |
... | ... |
@@ -253,8 +248,10 @@ char *internal_get_host_id(void) |
253 | 253 |
return NULL; |
254 | 254 |
|
255 | 255 |
printable_md5 = calloc(1, 37); |
256 |
- if (!(printable_md5)) |
|
256 |
+ if (!(printable_md5)) { |
|
257 |
+ free(devices); |
|
257 | 258 |
return NULL; |
259 |
+ } |
|
258 | 260 |
|
259 | 261 |
cli_md5_init(&ctx); |
260 | 262 |
for (i=0; devices[i].name != NULL; i++) |
... | ... |
@@ -223,8 +223,8 @@ void clamav_stats_add_sample(const char *virname, const unsigned char *md5, size |
223 | 223 |
|
224 | 224 |
sample->virus_name[i] = strdup((virname != NULL) ? virname : "[unknown]"); |
225 | 225 |
if (!(sample->virus_name[i])) { |
226 |
- free(sample); |
|
227 | 226 |
free(sample->virus_name); |
227 |
+ free(sample); |
|
228 | 228 |
if (sample == intel->samples) |
229 | 229 |
intel->samples = NULL; |
230 | 230 |
|
... | ... |
@@ -117,7 +117,8 @@ int connect_host(const char *host, const char *port, uint32_t timeout, int useAs |
117 | 117 |
|
118 | 118 |
if (!(p)) { |
119 | 119 |
freeaddrinfo(servinfo); |
120 |
- close(sockfd); |
|
120 |
+ if (sockfd >= 0) |
|
121 |
+ close(sockfd); |
|
121 | 122 |
return -1; |
122 | 123 |
} |
123 | 124 |
|
... | ... |
@@ -265,6 +266,8 @@ void submit_post(const char *host, const char *port, const char *method, const c |
265 | 265 |
if ((recvsz = recv(sockfd, buf, bufsz-1, 0) <= 0)) |
266 | 266 |
break; |
267 | 267 |
|
268 |
+ buf[bufsz-1] = '\0'; |
|
269 |
+ |
|
268 | 270 |
if (strstr(buf, "STATOK")) |
269 | 271 |
break; |
270 | 272 |
} |