diff options
Diffstat (limited to 'src/gns/gns_api.c')
-rw-r--r-- | src/gns/gns_api.c | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index fe378a922..e672c5687 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -832,35 +832,20 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
832 | struct GNUNET_GNS_LookupRequest *lr; | 832 | struct GNUNET_GNS_LookupRequest *lr; |
833 | size_t msize; | 833 | size_t msize; |
834 | struct PendingMessage *pending; | 834 | struct PendingMessage *pending; |
835 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey_enc; | ||
836 | size_t key_len; | ||
837 | char* pkey_tmp; | ||
838 | 835 | ||
839 | if (NULL == name) | 836 | if (NULL == name) |
840 | { | 837 | { |
841 | GNUNET_break (0); | 838 | GNUNET_break (0); |
842 | return NULL; | 839 | return NULL; |
843 | } | 840 | } |
844 | if (NULL != shorten_key) | ||
845 | { | ||
846 | pkey_enc = GNUNET_CRYPTO_ecc_encode_key (shorten_key); | ||
847 | GNUNET_assert (pkey_enc != NULL); | ||
848 | key_len = ntohs (pkey_enc->size); | ||
849 | } | ||
850 | else | ||
851 | { | ||
852 | pkey_enc = NULL; | ||
853 | key_len = 0; | ||
854 | } | ||
855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 841 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
856 | "Trying to lookup `%s' in GNS\n", | 842 | "Trying to lookup `%s' in GNS\n", |
857 | name); | 843 | name); |
858 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) | 844 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) |
859 | + key_len + strlen (name) + 1; | 845 | + strlen (name) + 1; |
860 | if (msize > UINT16_MAX) | 846 | if (msize > UINT16_MAX) |
861 | { | 847 | { |
862 | GNUNET_break (0); | 848 | GNUNET_break (0); |
863 | GNUNET_free (pkey_enc); | ||
864 | return NULL; | 849 | return NULL; |
865 | } | 850 | } |
866 | lr = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupRequest) + | 851 | lr = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupRequest) + |
@@ -882,26 +867,16 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, | |||
882 | lookup_msg->only_cached = htonl (only_cached); | 867 | lookup_msg->only_cached = htonl (only_cached); |
883 | if (NULL != zone) | 868 | if (NULL != zone) |
884 | { | 869 | { |
885 | lookup_msg->use_default_zone = htonl (GNUNET_NO); | 870 | lookup_msg->have_zone = htonl (GNUNET_YES); |
886 | memcpy (&lookup_msg->zone, zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | 871 | lookup_msg->zone = *zone; |
887 | } | 872 | } |
888 | else | ||
889 | { | ||
890 | lookup_msg->use_default_zone = htonl (GNUNET_YES); | ||
891 | memset (&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); | ||
892 | } | ||
893 | lookup_msg->type = htonl (type); | 873 | lookup_msg->type = htonl (type); |
894 | pkey_tmp = (char *) &lookup_msg[1]; | 874 | if (NULL != shorten_key) |
895 | if (pkey_enc != NULL) | ||
896 | { | 875 | { |
897 | lookup_msg->have_key = htonl (GNUNET_YES); | 876 | lookup_msg->have_key = htonl (GNUNET_YES); |
898 | memcpy (pkey_tmp, pkey_enc, key_len); | 877 | lookup_msg->shorten_key = *shorten_key; |
899 | } | 878 | } |
900 | else | 879 | memcpy (&lookup_msg[1], name, strlen (name) + 1); |
901 | lookup_msg->have_key = htonl (GNUNET_NO); | ||
902 | GNUNET_free_non_null (pkey_enc); | ||
903 | memcpy (&pkey_tmp[key_len], name, strlen (name) + 1); | ||
904 | |||
905 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, | 880 | GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, |
906 | handle->pending_tail, | 881 | handle->pending_tail, |
907 | pending); | 882 | pending); |