diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-12-15 07:17:48 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-12-15 07:17:48 +0000 |
commit | 5e0f453439e63444ba8d3909529be60877677344 (patch) | |
tree | 6d3cad0406240a42bf5a79e3ec42fadda5898f51 /src | |
parent | 5b4cc3b00e086a34f8dbcbf00f878f4a5850ea51 (diff) | |
download | gnunet-5e0f453439e63444ba8d3909529be60877677344.tar.gz gnunet-5e0f453439e63444ba8d3909529be60877677344.zip |
Fix memory corruption: new connection always makes copy of path.
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 16 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.h | 6 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 9f9955917..a4794e1e9 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -1607,7 +1607,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1607 | } | 1607 | } |
1608 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); | 1608 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); |
1609 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n"); | 1609 | LOG (GNUNET_ERROR_TYPE_DEBUG, " Creating connection\n"); |
1610 | c = GCC_new (cid, NULL, path_duplicate (path), own_pos); | 1610 | c = GCC_new (cid, NULL, path, own_pos); |
1611 | if (NULL == c) | 1611 | if (NULL == c) |
1612 | { | 1612 | { |
1613 | if (path->length - 1 == own_pos) | 1613 | if (path->length - 1 == own_pos) |
@@ -2470,14 +2470,26 @@ GCC_shutdown (void) | |||
2470 | } | 2470 | } |
2471 | 2471 | ||
2472 | 2472 | ||
2473 | /** | ||
2474 | * Create a connection. | ||
2475 | * | ||
2476 | * @param cid Connection ID (either created locally or imposed remotely). | ||
2477 | * @param t Tunnel this connection belongs to (or NULL); | ||
2478 | * @param path Path this connection has to use (copy is made). | ||
2479 | * @param own_pos Own position in the @c path path. | ||
2480 | * | ||
2481 | * @return Newly created connection, NULL in case of error (own id not in path). | ||
2482 | */ | ||
2473 | struct CadetConnection * | 2483 | struct CadetConnection * |
2474 | GCC_new (const struct GNUNET_CADET_Hash *cid, | 2484 | GCC_new (const struct GNUNET_CADET_Hash *cid, |
2475 | struct CadetTunnel *t, | 2485 | struct CadetTunnel *t, |
2476 | struct CadetPeerPath *p, | 2486 | struct CadetPeerPath *path, |
2477 | unsigned int own_pos) | 2487 | unsigned int own_pos) |
2478 | { | 2488 | { |
2479 | struct CadetConnection *c; | 2489 | struct CadetConnection *c; |
2490 | struct CadetPeerPath *p; | ||
2480 | 2491 | ||
2492 | p = path_duplicate (path); | ||
2481 | c = GNUNET_new (struct CadetConnection); | 2493 | c = GNUNET_new (struct CadetConnection); |
2482 | c->id = *cid; | 2494 | c->id = *cid; |
2483 | GNUNET_assert (GNUNET_OK == | 2495 | GNUNET_assert (GNUNET_OK == |
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index 6a2eff7de..b8edcdef9 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h | |||
@@ -265,15 +265,15 @@ GCC_shutdown (void); | |||
265 | * | 265 | * |
266 | * @param cid Connection ID (either created locally or imposed remotely). | 266 | * @param cid Connection ID (either created locally or imposed remotely). |
267 | * @param t Tunnel this connection belongs to (or NULL); | 267 | * @param t Tunnel this connection belongs to (or NULL); |
268 | * @param p Path this connection has to use. | 268 | * @param path Path this connection has to use (copy is made). |
269 | * @param own_pos Own position in the @c p path. | 269 | * @param own_pos Own position in the @c path path. |
270 | * | 270 | * |
271 | * @return Newly created connection, NULL in case of error (own id not in path). | 271 | * @return Newly created connection, NULL in case of error (own id not in path). |
272 | */ | 272 | */ |
273 | struct CadetConnection * | 273 | struct CadetConnection * |
274 | GCC_new (const struct GNUNET_CADET_Hash *cid, | 274 | GCC_new (const struct GNUNET_CADET_Hash *cid, |
275 | struct CadetTunnel *t, | 275 | struct CadetTunnel *t, |
276 | struct CadetPeerPath *p, | 276 | struct CadetPeerPath *path, |
277 | unsigned int own_pos); | 277 | unsigned int own_pos); |
278 | 278 | ||
279 | /** | 279 | /** |