git-svn: trunk@4886
Török Edvin authored on 2009/03/03 05:12:08... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Mon Mar 2 17:57:50 EET 2009 (edwin) |
|
2 |
+------------------------------------ |
|
3 |
+ * clamdtop/clamdtop.c: fix use-after-free. |
|
4 |
+ |
|
1 | 5 |
Mon Mar 2 19:54:41 CET 2009 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav: introduce cl_engine_settings_* API calls for copying settings |
... | ... |
@@ -59,7 +59,7 @@ |
59 | 59 |
/* Types, prototypes and globals*/ |
60 | 60 |
typedef struct connection { |
61 | 61 |
int sd; |
62 |
- const char *remote; |
|
62 |
+ char *remote; |
|
63 | 63 |
int tcp; |
64 | 64 |
struct timeval tv_conn; |
65 | 65 |
char *version; |
... | ... |
@@ -407,6 +407,7 @@ static void cleanup(void) |
407 | 407 |
close(global.conn[i].sd); |
408 | 408 |
} |
409 | 409 |
free(global.conn[i].version); |
410 |
+ free(global.conn[i].remote); |
|
410 | 411 |
} |
411 | 412 |
free(global.all_stats); |
412 | 413 |
free(global.conn); |
... | ... |
@@ -555,7 +556,11 @@ static int make_connection_real(const char *soname, conn_t *conn) |
555 | 555 |
return -1; |
556 | 556 |
} |
557 | 557 |
} |
558 |
- conn->remote = soname; |
|
558 |
+ if (conn->remote != soname) { |
|
559 |
+ /* when we reconnect, they are the same */ |
|
560 |
+ if (conn->remote) free(conn->remote); |
|
561 |
+ conn->remote = strdup(soname); |
|
562 |
+ } |
|
559 | 563 |
conn->sd = s; |
560 | 564 |
gettimeofday(&conn->tv_conn, NULL); |
561 | 565 |
tv.tv_sec = 4; |