Skip to content

Commit

Permalink
Added free statements on error in map_insert()
Browse files Browse the repository at this point in the history
  • Loading branch information
r-caamano committed May 8, 2024
1 parent e606329 commit a91d858
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/zfw.c
Expand Up @@ -2256,6 +2256,7 @@ void map_insert()
if (fd == -1)
{
printf("BPF_OBJ_GET: %s \n", strerror(errno));
free(orule);
close_maps(1);
}
map.map_fd = fd;
Expand Down Expand Up @@ -2292,6 +2293,8 @@ void map_insert()
else
{
printf("Unsupported Protocol\n");
free(port_mapping);
free(orule);
close(fd);
close_maps(1);
}
Expand All @@ -2307,6 +2310,8 @@ void map_insert()
if (!rule.port_mapping[index].low_port)
{
printf("memcpy failed");
free(port_mapping);
free(orule);
close(fd);
close_maps(1);
}
Expand All @@ -2323,6 +2328,9 @@ void map_insert()
if (count_fd == -1)
{
printf("BPF_OBJ_GET: %s \n", strerror(errno));
free(port_mapping);
free(orule);
close(fd);
close_maps(1);
}
uint32_t count_key = 0;
Expand Down Expand Up @@ -2356,6 +2364,8 @@ void map_insert()
if (!(orule->port_mapping[index].low_port == index))
{
printf("Insert failed\n");
free(port_mapping);
free(orule);
close(fd);
close_maps(1);
}
Expand All @@ -2365,6 +2375,9 @@ void map_insert()
if (result)
{
printf("MAP_UPDATE_ELEM: %s \n", strerror(errno));
free(port_mapping);
free(orule);
close(fd);
close_maps(1);
}
free(port_mapping);
Expand Down

0 comments on commit a91d858

Please sign in to comment.