aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-29 22:48:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-29 22:48:40 +0000
commit6bee2a739c8e0c5090b0a75ad9c42e1cbd7f0b66 (patch)
treee14c6a11b6511651255f666568e500d9877804a9 /src/gns
parent3ca59011e56d618eb33f4b59aaaf98f8fb2d3826 (diff)
downloadgnunet-6bee2a739c8e0c5090b0a75ad9c42e1cbd7f0b66.tar.gz
gnunet-6bee2a739c8e0c5090b0a75ad9c42e1cbd7f0b66.zip
-undo Martin undoing my 0-termination checks
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns.c103
1 files changed, 54 insertions, 49 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 0b617b0cd..88e1f9d58 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -17,9 +17,7 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20
21/** 20/**
22 *
23 * @file gns/gnunet-service-gns.c 21 * @file gns/gnunet-service-gns.c
24 * @brief GNUnet GNS service 22 * @brief GNUnet GNS service
25 * @author Martin Schanzenbach 23 * @author Martin Schanzenbach
@@ -729,43 +727,38 @@ process_shorten_in_root_zone_lookup (void *cls,
729 */ 727 */
730static void 728static void
731process_private_in_root_zone_lookup (void *cls, 729process_private_in_root_zone_lookup (void *cls,
732 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 730 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
733 struct GNUNET_TIME_Absolute expiration, 731 struct GNUNET_TIME_Absolute expiration,
734 const char *name, 732 const char *name,
735 unsigned int rd_count, 733 unsigned int rd_count,
736 const struct GNUNET_NAMESTORE_RecordData *rd, 734 const struct GNUNET_NAMESTORE_RecordData *rd,
737 const struct GNUNET_CRYPTO_RsaSignature *signature) 735 const struct GNUNET_CRYPTO_RsaSignature *signature)
738{ 736{
739 struct ClientShortenHandle *csh = cls; 737 struct ClientShortenHandle *csh = cls;
740 csh->namestore_task = NULL;
741 738
742 if (rd_count == 0) 739 csh->namestore_task = NULL;
740 if (0 == rd_count)
743 { 741 {
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
745 "No private zone in root zone\n"); 743 "No private zone in root zone\n");
746
747 strcpy (csh->private_zone_id, ""); 744 strcpy (csh->private_zone_id, "");
748
749 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, 745 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
750 &csh->root_zone, 746 &csh->root_zone,
751 &csh->shorten_zone, 747 &csh->shorten_zone,
752 &process_shorten_in_root_zone_lookup, 748 &process_shorten_in_root_zone_lookup,
753 csh); 749 csh);
754 return; 750 return;
755 } 751 }
756 752 GNUNET_break (1 == rd_count);
757 GNUNET_assert (rd_count == 1);
758
759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
760 "Private zone %s found in root zone\n", name); 754 "Private zone `%s' found in root zone\n",
761 755 name);
762 strcpy (csh->private_zone_id, name); 756 strcpy (csh->private_zone_id, name);
763
764 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, 757 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
765 &csh->private_zone, 758 &csh->private_zone,
766 &csh->shorten_zone, 759 &csh->shorten_zone,
767 &process_shorten_in_private_zone_lookup, 760 &process_shorten_in_private_zone_lookup,
768 csh); 761 csh);
769} 762}
770 763
771 764
@@ -780,12 +773,11 @@ start_shorten_name (struct ClientShortenHandle *csh)
780{ 773{
781 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 774 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
782 "Looking for private zone name in root zone\n"); 775 "Looking for private zone name in root zone\n");
783
784 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, 776 csh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
785 &csh->root_zone, 777 &csh->root_zone,
786 &csh->private_zone, 778 &csh->private_zone,
787 &process_private_in_root_zone_lookup, 779 &process_private_in_root_zone_lookup,
788 csh); 780 csh);
789} 781}
790 782
791 783
@@ -806,6 +798,7 @@ handle_shorten (void *cls,
806 char name[MAX_DNS_NAME_LENGTH]; 798 char name[MAX_DNS_NAME_LENGTH];
807 char* nameptr = name; 799 char* nameptr = name;
808 uint16_t msg_size; 800 uint16_t msg_size;
801 const struct GNUNET_GNS_ClientShortenMessage *sh_msg;
809 802
810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); 803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN");
811 msg_size = ntohs (message->size); 804 msg_size = ntohs (message->size);
@@ -815,11 +808,14 @@ handle_shorten (void *cls,
815 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 808 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
816 return; 809 return;
817 } 810 }
818 811 sh_msg = (const struct GNUNET_GNS_ClientShortenMessage *) message;
819 812 utf_in = (const char *) &sh_msg[1];
820 const struct GNUNET_GNS_ClientShortenMessage *sh_msg = 813 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientShortenMessage) - 1])
821 (const struct GNUNET_GNS_ClientShortenMessage *) message; 814 {
822 815 GNUNET_break (0);
816 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
817 return;
818 }
823 csh = GNUNET_malloc(sizeof (struct ClientShortenHandle)); 819 csh = GNUNET_malloc(sizeof (struct ClientShortenHandle));
824 csh->client = client; 820 csh->client = client;
825 csh->request_id = sh_msg->id; 821 csh->request_id = sh_msg->id;
@@ -884,16 +880,16 @@ send_get_auth_response(void *cls, const char* name)
884 struct ClientGetAuthHandle *cah = cls; 880 struct ClientGetAuthHandle *cah = cls;
885 struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg; 881 struct GNUNET_GNS_ClientGetAuthResultMessage *rmsg;
886 882
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n", 883 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
884 "Sending `%s' message with `%s'\n",
888 "GET_AUTH_RESULT", name); 885 "GET_AUTH_RESULT", name);
889 if (name != NULL) 886 if (NULL != name)
890 { 887 {
891 GNUNET_STATISTICS_update (statistics, 888 GNUNET_STATISTICS_update (statistics,
892 "Authorities resolved", 1, GNUNET_NO); 889 "Authorities resolved", 1, GNUNET_NO);
893 } 890 }
894 if (name == NULL) 891 if (NULL == name)
895 name = ""; 892 name = "";
896
897 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage) 893 rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientGetAuthResultMessage)
898 + strlen(name) + 1); 894 + strlen(name) + 1);
899 895
@@ -932,6 +928,7 @@ handle_get_authority (void *cls,
932 char name[MAX_DNS_NAME_LENGTH]; 928 char name[MAX_DNS_NAME_LENGTH];
933 char* nameptr = name; 929 char* nameptr = name;
934 uint16_t msg_size; 930 uint16_t msg_size;
931 const struct GNUNET_GNS_ClientGetAuthMessage *sh_msg;
935 932
936 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH"); 933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "GET_AUTH");
937 msg_size = ntohs(message->size); 934 msg_size = ntohs(message->size);
@@ -942,13 +939,15 @@ handle_get_authority (void *cls,
942 return; 939 return;
943 } 940 }
944 GNUNET_SERVER_notification_context_add (nc, client); 941 GNUNET_SERVER_notification_context_add (nc, client);
945 942 sh_msg = (const struct GNUNET_GNS_ClientGetAuthMessage *) message;
946 struct GNUNET_GNS_ClientGetAuthMessage *sh_msg = 943 utf_in = (const char *) &sh_msg[1];
947 (struct GNUNET_GNS_ClientGetAuthMessage *) message; 944 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientGetAuthMessage) - 1])
948 945 {
949 GNUNET_STRINGS_utf8_tolower((const char*)&sh_msg[1], &nameptr); 946 GNUNET_break (0);
950 947 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
951 948 return;
949 }
950 GNUNET_STRINGS_utf8_tolower(utf_in, &nameptr);
952 cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle)); 951 cah = GNUNET_malloc(sizeof(struct ClientGetAuthHandle));
953 cah->client = client; 952 cah->client = client;
954 cah->request_id = sh_msg->id; 953 cah->request_id = sh_msg->id;
@@ -1087,7 +1086,6 @@ handle_lookup(void *cls,
1087 } 1086 }
1088 sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message; 1087 sh_msg = (const struct GNUNET_GNS_ClientLookupMessage *) message;
1089 GNUNET_SERVER_notification_context_add (nc, client); 1088 GNUNET_SERVER_notification_context_add (nc, client);
1090
1091 if (GNUNET_YES == ntohl (sh_msg->have_key)) 1089 if (GNUNET_YES == ntohl (sh_msg->have_key))
1092 { 1090 {
1093 pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *) &sh_msg[1]; 1091 pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *) &sh_msg[1];
@@ -1098,7 +1096,14 @@ handle_lookup(void *cls,
1098 else 1096 else
1099 { 1097 {
1100 key = NULL; 1098 key = NULL;
1101 GNUNET_STRINGS_utf8_tolower ((char*) &sh_msg[1], &nameptr); 1099 utf_in = (const char *) &sh_msg[1];
1100 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1])
1101 {
1102 GNUNET_break (0);
1103 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1104 return;
1105 }
1106 GNUNET_STRINGS_utf8_tolower(utf_in, &nameptr);
1102 } 1107 }
1103 1108
1104 namelen = strlen(name)+1; 1109 namelen = strlen(name)+1;