diff options
Diffstat (limited to 'src/namestore/plugin_rest_namestore.c')
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index 3801431b2..f14707cce 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -641,16 +641,17 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle, | |||
641 | { | 641 | { |
642 | handle->emsg = GNUNET_strdup("Invalid data"); | 642 | handle->emsg = GNUNET_strdup("Invalid data"); |
643 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 643 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
644 | GNUNET_free_non_null(gns_record); | 644 | GNUNET_JSON_parse_free(gnsspec); |
645 | json_decref (data_js); | 645 | json_decref (data_js); |
646 | return; | 646 | return; |
647 | } | 647 | } |
648 | handle->rd = gns_record; | ||
649 | |||
648 | name_json = json_object_get(data_js, "label"); | 650 | name_json = json_object_get(data_js, "label"); |
649 | if (!json_is_string(name_json)) | 651 | if (!json_is_string(name_json)) |
650 | { | 652 | { |
651 | handle->emsg = GNUNET_strdup("Missing name"); | 653 | handle->emsg = GNUNET_strdup("Missing name"); |
652 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 654 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
653 | GNUNET_free_non_null(gns_record); | ||
654 | json_decref (data_js); | 655 | json_decref (data_js); |
655 | return; | 656 | return; |
656 | } | 657 | } |
@@ -659,7 +660,6 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle, | |||
659 | { | 660 | { |
660 | handle->emsg = GNUNET_strdup("Missing name"); | 661 | handle->emsg = GNUNET_strdup("Missing name"); |
661 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 662 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
662 | GNUNET_free_non_null(gns_record); | ||
663 | json_decref (data_js); | 663 | json_decref (data_js); |
664 | return; | 664 | return; |
665 | } | 665 | } |
@@ -667,12 +667,10 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle, | |||
667 | { | 667 | { |
668 | handle->emsg = GNUNET_strdup("Missing name"); | 668 | handle->emsg = GNUNET_strdup("Missing name"); |
669 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 669 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
670 | GNUNET_free_non_null(gns_record); | ||
671 | json_decref (data_js); | 670 | json_decref (data_js); |
672 | return; | 671 | return; |
673 | } | 672 | } |
674 | json_decref (data_js); | 673 | json_decref (data_js); |
675 | handle->rd = gns_record; | ||
676 | 674 | ||
677 | //change zone if pubkey or name specified | 675 | //change zone if pubkey or name specified |
678 | GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY, | 676 | GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY, |
@@ -711,6 +709,12 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle, | |||
711 | { | 709 | { |
712 | handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); | 710 | handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego); |
713 | } | 711 | } |
712 | if (NULL == handle->zone_pkey) | ||
713 | { | ||
714 | handle->emsg = GNUNET_strdup("No default identity for namestore"); | ||
715 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
716 | return; | ||
717 | } | ||
714 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, | 718 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, |
715 | handle->zone_pkey, | 719 | handle->zone_pkey, |
716 | handle->label_name, | 720 | handle->label_name, |
@@ -813,6 +817,14 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle, | |||
813 | } | 817 | } |
814 | handle->label_name = GNUNET_strdup( | 818 | handle->label_name = GNUNET_strdup( |
815 | GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key)); | 819 | GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key)); |
820 | |||
821 | if (NULL == handle->zone_pkey) | ||
822 | { | ||
823 | handle->emsg = GNUNET_strdup("No default identity for namestore"); | ||
824 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
825 | return; | ||
826 | } | ||
827 | |||
816 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, | 828 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, |
817 | handle->zone_pkey, | 829 | handle->zone_pkey, |
818 | handle->label_name, | 830 | handle->label_name, |