aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-06 16:05:57 +0200
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-06 16:05:57 +0200
commit070a1c2e37fe8930bad59cbd06d6a0f55a8364f0 (patch)
treefb498dbe72f0145bf3d250ba335d6ecb5341b632
parent7bd650c1a944be9e772a907cb269ac0b50f98de2 (diff)
downloadgnunet-070a1c2e37fe8930bad59cbd06d6a0f55a8364f0.tar.gz
gnunet-070a1c2e37fe8930bad59cbd06d6a0f55a8364f0.zip
ensure ego identifiers are lowercase
-rw-r--r--src/identity/gnunet-service-identity.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index 6b8e21806..266f5ccc3 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -371,11 +371,12 @@ handle_get_default_message (void *cls,
371 struct GNUNET_MQ_Envelope *env; 371 struct GNUNET_MQ_Envelope *env;
372 struct GNUNET_SERVICE_Client *client = cls; 372 struct GNUNET_SERVICE_Client *client = cls;
373 struct Ego *ego; 373 struct Ego *ego;
374 const char *name; 374 char *name;
375 char *identifier; 375 char *identifier;
376 376
377 377
378 name = (const char *) &gdm[1]; 378 name = GNUNET_strdup ((const char *) &gdm[1]);
379 GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
380 "Received GET_DEFAULT for service `%s' from client\n", 381 "Received GET_DEFAULT for service `%s' from client\n",
381 name); 382 name);
@@ -387,6 +388,7 @@ handle_get_default_message (void *cls,
387 { 388 {
388 send_result_code (client, 1, gettext_noop ("no default known")); 389 send_result_code (client, 1, gettext_noop ("no default known"));
389 GNUNET_SERVICE_client_continue (client); 390 GNUNET_SERVICE_client_continue (client);
391 GNUNET_free (name);
390 return; 392 return;
391 } 393 }
392 for (ego = ego_head; NULL != ego; ego = ego->next) 394 for (ego = ego_head; NULL != ego; ego = ego->next)
@@ -399,6 +401,7 @@ handle_get_default_message (void *cls,
399 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); 401 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
400 GNUNET_SERVICE_client_continue (client); 402 GNUNET_SERVICE_client_continue (client);
401 GNUNET_free (identifier); 403 GNUNET_free (identifier);
404 GNUNET_free (name);
402 return; 405 return;
403 } 406 }
404 } 407 }
@@ -406,6 +409,7 @@ handle_get_default_message (void *cls,
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
407 "Failed to find ego `%s'\n", 410 "Failed to find ego `%s'\n",
408 name); 411 name);
412 GNUNET_free (name);
409 send_result_code (client, 1, 413 send_result_code (client, 1,
410 gettext_noop ("default configured, but ego unknown (internal error)")); 414 gettext_noop ("default configured, but ego unknown (internal error)"));
411 GNUNET_SERVICE_client_continue (client); 415 GNUNET_SERVICE_client_continue (client);
@@ -477,9 +481,11 @@ handle_set_default_message (void *cls,
477{ 481{
478 struct Ego *ego; 482 struct Ego *ego;
479 struct GNUNET_SERVICE_Client *client = cls; 483 struct GNUNET_SERVICE_Client *client = cls;
480 const char *str; 484 char *str;
485
486 str = GNUNET_strdup ((const char *) &sdm[1]);
487 GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str);
481 488
482 str = (const char *) &sdm[1];
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
484 "Received SET_DEFAULT for service `%s' from client\n", 490 "Received SET_DEFAULT for service `%s' from client\n",
485 str); 491 str);
@@ -500,10 +506,12 @@ handle_set_default_message (void *cls,
500 subsystem_cfg_file); 506 subsystem_cfg_file);
501 send_result_code (client, 0, NULL); 507 send_result_code (client, 0, NULL);
502 GNUNET_SERVICE_client_continue (client); 508 GNUNET_SERVICE_client_continue (client);
509 GNUNET_free (str);
503 return; 510 return;
504 } 511 }
505 } 512 }
506 send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); 513 send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
514 GNUNET_free (str);
507 GNUNET_SERVICE_client_continue (client); 515 GNUNET_SERVICE_client_continue (client);
508} 516}
509 517
@@ -585,12 +593,13 @@ handle_create_message (void *cls,
585{ 593{
586 struct GNUNET_SERVICE_Client *client = cls; 594 struct GNUNET_SERVICE_Client *client = cls;
587 struct Ego *ego; 595 struct Ego *ego;
588 const char *str; 596 char *str;
589 char *fn; 597 char *fn;
590 598
591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 599 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
592 "Received CREATE message from client\n"); 600 "Received CREATE message from client\n");
593 str = (const char *) &crm[1]; 601 str = GNUNET_strdup ((const char *) &crm[1]);
602 GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str);
594 for (ego = ego_head; NULL != ego; ego = ego->next) 603 for (ego = ego_head; NULL != ego; ego = ego->next)
595 { 604 {
596 if (0 == strcmp (ego->identifier, 605 if (0 == strcmp (ego->identifier,
@@ -598,6 +607,7 @@ handle_create_message (void *cls,
598 { 607 {
599 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego")); 608 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego"));
600 GNUNET_SERVICE_client_continue (client); 609 GNUNET_SERVICE_client_continue (client);
610 GNUNET_free (str);
601 return; 611 return;
602 } 612 }
603 } 613 }
@@ -620,6 +630,7 @@ handle_create_message (void *cls,
620 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 630 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
621 "write", fn); 631 "write", fn);
622 GNUNET_free (fn); 632 GNUNET_free (fn);
633 GNUNET_free (str);
623 notify_listeners (ego); 634 notify_listeners (ego);
624 GNUNET_SERVICE_client_continue (client); 635 GNUNET_SERVICE_client_continue (client);
625} 636}
@@ -726,18 +737,22 @@ handle_rename_message (void *cls,
726{ 737{
727 uint16_t old_name_len; 738 uint16_t old_name_len;
728 struct Ego *ego; 739 struct Ego *ego;
729 const char *old_name; 740 char *old_name;
730 const char *new_name; 741 char *new_name;
731 struct RenameContext rename_ctx; 742 struct RenameContext rename_ctx;
732 struct GNUNET_SERVICE_Client *client = cls; 743 struct GNUNET_SERVICE_Client *client = cls;
733 char *fn_old; 744 char *fn_old;
734 char *fn_new; 745 char *fn_new;
746 const char *old_name_tmp;
735 747
736 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
737 "Received RENAME message from client\n"); 749 "Received RENAME message from client\n");
738 old_name_len = ntohs (rm->old_name_len); 750 old_name_len = ntohs (rm->old_name_len);
739 old_name = (const char *) &rm[1]; 751 old_name_tmp = (const char *) &rm[1];
740 new_name = &old_name[old_name_len]; 752 old_name = GNUNET_strdup (old_name_tmp);
753 GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
754 new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
755 GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], old_name);
741 756
742 /* check if new name is already in use */ 757 /* check if new name is already in use */
743 for (ego = ego_head; NULL != ego; ego = ego->next) 758 for (ego = ego_head; NULL != ego; ego = ego->next)
@@ -747,6 +762,8 @@ handle_rename_message (void *cls,
747 { 762 {
748 send_result_code (client, 1, gettext_noop ("target name already exists")); 763 send_result_code (client, 1, gettext_noop ("target name already exists"));
749 GNUNET_SERVICE_client_continue (client); 764 GNUNET_SERVICE_client_continue (client);
765 GNUNET_free (old_name);
766 GNUNET_free (new_name);
750 return; 767 return;
751 } 768 }
752 } 769 }
@@ -776,6 +793,8 @@ handle_rename_message (void *cls,
776 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); 793 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old);
777 GNUNET_free (fn_old); 794 GNUNET_free (fn_old);
778 GNUNET_free (fn_new); 795 GNUNET_free (fn_new);
796 GNUNET_free (old_name);
797 GNUNET_free (new_name);
779 notify_listeners (ego); 798 notify_listeners (ego);
780 send_result_code (client, 0, NULL); 799 send_result_code (client, 0, NULL);
781 GNUNET_SERVICE_client_continue (client); 800 GNUNET_SERVICE_client_continue (client);
@@ -785,6 +804,8 @@ handle_rename_message (void *cls,
785 804
786 /* failed to locate old name */ 805 /* failed to locate old name */
787 send_result_code (client, 1, gettext_noop ("no matching ego found")); 806 send_result_code (client, 1, gettext_noop ("no matching ego found"));
807 GNUNET_free (old_name);
808 GNUNET_free (new_name);
788 GNUNET_SERVICE_client_continue (client); 809 GNUNET_SERVICE_client_continue (client);
789} 810}
790 811
@@ -868,13 +889,15 @@ handle_delete_message (void *cls,
868 const struct DeleteMessage *dm) 889 const struct DeleteMessage *dm)
869{ 890{
870 struct Ego *ego; 891 struct Ego *ego;
871 const char *name; 892 char *name;
872 char *fn; 893 char *fn;
873 struct GNUNET_SERVICE_Client *client = cls; 894 struct GNUNET_SERVICE_Client *client = cls;
874 895
875 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
876 "Received DELETE message from client\n"); 897 "Received DELETE message from client\n");
877 name = (const char *) &dm[1]; 898 name = GNUNET_strdup ((const char *) &dm[1]);
899 GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
900
878 for (ego = ego_head; NULL != ego; ego = ego->next) 901 for (ego = ego_head; NULL != ego; ego = ego->next)
879 { 902 {
880 if (0 == strcmp (ego->identifier, 903 if (0 == strcmp (ego->identifier,
@@ -901,6 +924,7 @@ handle_delete_message (void *cls,
901 notify_listeners (ego); 924 notify_listeners (ego);
902 GNUNET_free (ego->pk); 925 GNUNET_free (ego->pk);
903 GNUNET_free (ego); 926 GNUNET_free (ego);
927 GNUNET_free (name);
904 send_result_code (client, 0, NULL); 928 send_result_code (client, 0, NULL);
905 GNUNET_SERVICE_client_continue (client); 929 GNUNET_SERVICE_client_continue (client);
906 return; 930 return;
@@ -908,6 +932,7 @@ handle_delete_message (void *cls,
908 } 932 }
909 933
910 send_result_code (client, 1, gettext_noop ("no matching ego found")); 934 send_result_code (client, 1, gettext_noop ("no matching ego found"));
935 GNUNET_free (name);
911 GNUNET_SERVICE_client_continue (client); 936 GNUNET_SERVICE_client_continue (client);
912} 937}
913 938