diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-04 12:31:45 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-04 12:31:45 +0000 |
commit | dd8298b9661dfbd1920702ee1d2ce05e94508165 (patch) | |
tree | aabaa2b729128d2471d28570319af0132f3fcf0e /src/transport/gnunet-service-transport_neighbours.c | |
parent | 639cea2048b7e2d42c0c686584d3df6cc84de9c4 (diff) | |
download | gnunet-dd8298b9661dfbd1920702ee1d2ce05e94508165.tar.gz gnunet-dd8298b9661dfbd1920702ee1d2ce05e94508165.zip |
fixing 3299: use after free caused by shutdown order neighbours & plugins
Diffstat (limited to 'src/transport/gnunet-service-transport_neighbours.c')
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 45f1575fe..42ff650c1 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -799,6 +799,8 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
799 | n->primary_address.bandwidth_out); | 799 | n->primary_address.bandwidth_out); |
800 | } | 800 | } |
801 | 801 | ||
802 | #if 0 | ||
803 | TODO: Implement this | ||
802 | /** | 804 | /** |
803 | * Clear the primary address of a neighbour since this primary address is not | 805 | * Clear the primary address of a neighbour since this primary address is not |
804 | * valid anymore and notify monitoring about it | 806 | * valid anymore and notify monitoring about it |
@@ -811,6 +813,8 @@ unset_primary_address (struct NeighbourMapEntry *n) | |||
811 | 813 | ||
812 | } | 814 | } |
813 | 815 | ||
816 | #endif | ||
817 | |||
814 | 818 | ||
815 | /** | 819 | /** |
816 | * Free a neighbour map entry. | 820 | * Free a neighbour map entry. |
@@ -1731,13 +1735,17 @@ GST_neighbours_register_quota_notification(void *cls, | |||
1731 | struct QuotaNotificationRequest *qnr; | 1735 | struct QuotaNotificationRequest *qnr; |
1732 | struct QNR_LookContext qnr_ctx; | 1736 | struct QNR_LookContext qnr_ctx; |
1733 | 1737 | ||
1738 | if (NULL == registered_quota_notifications) | ||
1739 | { | ||
1740 | return; /* init or shutdown */ | ||
1741 | } | ||
1742 | |||
1734 | qnr_ctx.peer = (*peer); | 1743 | qnr_ctx.peer = (*peer); |
1735 | qnr_ctx.plugin = plugin; | 1744 | qnr_ctx.plugin = plugin; |
1736 | qnr_ctx.session = session; | 1745 | qnr_ctx.session = session; |
1737 | qnr_ctx.res = NULL; | 1746 | qnr_ctx.res = NULL; |
1738 | int res; | ||
1739 | 1747 | ||
1740 | res = GNUNET_CONTAINER_multipeermap_get_multiple (registered_quota_notifications, | 1748 | GNUNET_CONTAINER_multipeermap_get_multiple (registered_quota_notifications, |
1741 | peer, &find_notification_request, &qnr_ctx); | 1749 | peer, &find_notification_request, &qnr_ctx); |
1742 | if (NULL != qnr_ctx.res) | 1750 | if (NULL != qnr_ctx.res) |
1743 | { | 1751 | { |
@@ -1764,13 +1772,18 @@ GST_neighbours_unregister_quota_notification(void *cls, | |||
1764 | const struct GNUNET_PeerIdentity *peer, const char *plugin, struct Session *session) | 1772 | const struct GNUNET_PeerIdentity *peer, const char *plugin, struct Session *session) |
1765 | { | 1773 | { |
1766 | struct QNR_LookContext qnr_ctx; | 1774 | struct QNR_LookContext qnr_ctx; |
1775 | |||
1776 | if (NULL == registered_quota_notifications) | ||
1777 | { | ||
1778 | return; /* init or shutdown */ | ||
1779 | } | ||
1780 | |||
1767 | qnr_ctx.peer = (*peer); | 1781 | qnr_ctx.peer = (*peer); |
1768 | qnr_ctx.plugin = plugin; | 1782 | qnr_ctx.plugin = plugin; |
1769 | qnr_ctx.session = session; | 1783 | qnr_ctx.session = session; |
1770 | qnr_ctx.res = NULL; | 1784 | qnr_ctx.res = NULL; |
1771 | int res; | ||
1772 | 1785 | ||
1773 | res = GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications, | 1786 | GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications, |
1774 | &find_notification_request, &qnr_ctx); | 1787 | &find_notification_request, &qnr_ctx); |
1775 | if (NULL == qnr_ctx.res) | 1788 | if (NULL == qnr_ctx.res) |
1776 | { | 1789 | { |
@@ -1791,7 +1804,7 @@ GST_neighbours_unregister_quota_notification(void *cls, | |||
1791 | static int | 1804 | static int |
1792 | notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value) | 1805 | notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
1793 | { | 1806 | { |
1794 | struct NeighbourMapEntry *n = cls; | 1807 | /* struct NeighbourMapEntry *n = cls; */ |
1795 | struct QuotaNotificationRequest *qnr = value; | 1808 | struct QuotaNotificationRequest *qnr = value; |
1796 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 1809 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
1797 | struct GNUNET_TIME_Relative delay; | 1810 | struct GNUNET_TIME_Relative delay; |
@@ -1819,11 +1832,12 @@ int | |||
1819 | free_notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, | 1832 | free_notification_cb(void *cls, const struct GNUNET_PeerIdentity *key, |
1820 | void *value) | 1833 | void *value) |
1821 | { | 1834 | { |
1822 | struct NeighbourMapEntry *n = cls; | 1835 | /* struct NeighbourMapEntry *n = cls; */ |
1823 | struct QuotaNotificationRequest *qnr = value; | 1836 | struct QuotaNotificationRequest *qnr = value; |
1824 | 1837 | ||
1825 | GNUNET_CONTAINER_multipeermap_remove (registered_quota_notifications, key, | 1838 | GNUNET_CONTAINER_multipeermap_remove (registered_quota_notifications, key, |
1826 | qnr); | 1839 | qnr); |
1840 | GNUNET_free(qnr->plugin); | ||
1827 | GNUNET_free(qnr); | 1841 | GNUNET_free(qnr); |
1828 | 1842 | ||
1829 | return GNUNET_OK; | 1843 | return GNUNET_OK; |
@@ -3868,6 +3882,7 @@ GST_neighbours_stop () | |||
3868 | GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications, | 3882 | GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications, |
3869 | &free_notification_cb, NULL); | 3883 | &free_notification_cb, NULL); |
3870 | GNUNET_CONTAINER_multipeermap_destroy (registered_quota_notifications); | 3884 | GNUNET_CONTAINER_multipeermap_destroy (registered_quota_notifications); |
3885 | registered_quota_notifications = NULL; | ||
3871 | 3886 | ||
3872 | neighbours = NULL; | 3887 | neighbours = NULL; |
3873 | callback_cls = NULL; | 3888 | callback_cls = NULL; |