Skip to contentSkip to conversation

alfred: Check if tg hash was really initialized

PATCH In review Sven Eckelmann 2 participants 5 messages Jun 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 alfred: Check if tg hash was really initialized

The return value check after the tg_hash_new call must actually check the return value and not some other datastructure.

Fixes a7bc3d9a2b3f ("alfred: Cache the global translation table entries")
---
 server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
server.c +1 -1
index 1e358cf..9774281 100644
@@ -232,7 +232,7 @@ static void update_server_info(struct globals *globals)
 
 	if (strcmp(globals->mesh_iface, "none") != 0) {
 		tg_hash = tg_hash_new(globals->mesh_iface);
-		if (!globals->data_hash) {
+		if (!tg_hash) {
 			fprintf(stderr, "Failed to create translation hash\n");
 			return;
 		}
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/3 alfred: Always initialize orig cache hash pointer

The initialization of the cache can be disabled when mesh interface is "none". We must therefore make sure that the remaining code is not accessing the uninitialized pointer to the originator cache.

Fixes e50d18c39f92 ("alfred: Cache the TQ values for each originator")
---
 server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
server.c +1 -1
index 9774281..e7f691c 100644
@@ -224,7 +224,7 @@ static void update_server_info(struct globals *globals)
 	struct interface *interface;
 	struct ether_addr *macaddr;
 	struct hashtable_t *tg_hash;
-	struct hashtable_t *orig_hash;
+	struct hashtable_t *orig_hash = NULL;
 
 	/* TQ is not used for master sync mode */
 	if (globals->opmode == OPMODE_MASTER)
Signature · 1 line
2.11.0
#2 lore raw

PATCH 3/3 alfred: Always initialize translation cache hash pointer

In reply to Sven Eckelmann

The initialization of the cache can be disabled when mesh interface is "none". We must therefore make sure that the remaining code is not accessing the uninitialized pointer to the translation cache.

Fixes a7bc3d9a2b3f ("alfred: Cache the global translation table entries")
---
 server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
server.c +1 -1
index e7f691c..b6f0812 100644
@@ -223,7 +223,7 @@ static void update_server_info(struct globals *globals)
 	struct hash_it_t *hashit = NULL;
 	struct interface *interface;
 	struct ether_addr *macaddr;
-	struct hashtable_t *tg_hash;
+	struct hashtable_t *tg_hash = NULL;
 	struct hashtable_t *orig_hash = NULL;
 
 	/* TQ is not used for master sync mode */
Signature · 1 line
2.11.0
#3 lore raw
In reply to Sven Eckelmann

Thanks a lot for fixing that thing I missed and the initialization problems. I guess this also takes of the covery splats. I've picked all patches as they are.

Thanks,
Simon

Quoted 22 lines · CEST Sven Eckelmann

The return value check after the tg_hash_new call must actually check the return value and not some other datastructure.

Fixes a7bc3d9a2b3f ("alfred: Cache the global translation table entries")
---
 server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
server.c +1 -1
index 1e358cf..9774281 100644
@@ -232,7 +232,7 @@ static void update_server_info(struct globals *globals)
 
 	if (strcmp(globals->mesh_iface, "none") != 0) {
 		tg_hash = tg_hash_new(globals->mesh_iface);
-		if (!globals->data_hash) {
+		if (!tg_hash) {
 			fprintf(stderr, "Failed to create translation hash\n");
 			return;
 		}
#4 lore raw
Quoted 3 lines · On Donnerstag, 1. Juni 2017 10:15:20 CEST Simon Wunderlich wrote:

Thanks a lot for fixing that thing I missed and the initialization problems. I guess this also takes of the covery splats. I've picked all patches as they are.

Can you please also push patches 2 + 3.

Thanks,
Sven