From ff1407f3502c2294dbf9f2c6a753b9e3fa04973a Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Thu, 5 Apr 2012 10:16:53 +0000 Subject: [PATCH] - max name len --- src/gns/gnunet-service-gns.c | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index c2ea2a44d..665872296 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -466,7 +466,6 @@ static void handle_shorten(void *cls, return; } - GNUNET_SERVER_notification_context_add (nc, client); struct GNUNET_GNS_ClientShortenMessage *sh_msg = (struct GNUNET_GNS_ClientShortenMessage *) message; @@ -487,6 +486,16 @@ static void handle_shorten(void *cls, GNUNET_STRINGS_utf8_tolower((char*)&sh_msg[1], &nameptr); if (strlen (name) < strlen(GNUNET_GNS_TLD)) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "SHORTEN: %s is too short", name); + csh->name = NULL; + send_shorten_response(csh, name); + return; + } + + if (strlen (name) > MAX_DNS_NAME_LENGTH) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "SHORTEN: %s is too long", name); csh->name = NULL; send_shorten_response(csh, name); return; @@ -501,6 +510,8 @@ static void handle_shorten(void *cls, return; } + GNUNET_SERVER_notification_context_add (nc, client); + /* Start shortening */ if (GNUNET_YES == auto_import_pkey) gns_resolver_shorten_name(zone_hash, name, zone_key, @@ -607,17 +618,25 @@ static void handle_get_authority(void *cls, if (strlen(name) < strlen(GNUNET_GNS_TLD)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s is too short. Returning\n", name); + "GET_AUTH: %s is too short. Returning\n", name); cah->name = NULL; send_get_auth_response(cah, name); return; } - + + if (strlen (name) > MAX_DNS_NAME_LENGTH) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "GET_AUTH: %s is too long", name); + cah->name = NULL; + send_get_auth_response(cah, name); + return; + } + if (strcmp(name+strlen(name)-strlen(GNUNET_GNS_TLD), GNUNET_GNS_TLD) != 0) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s is not our domain. Returning\n", name); + "GET_AUTH: %s is not our domain. Returning\n", name); cah->name = NULL; send_get_auth_response(cah, name); return; @@ -626,7 +645,7 @@ static void handle_get_authority(void *cls, if (strcmp(name, GNUNET_GNS_TLD) == 0) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s is us. Returning\n", name); + "GET_AUTH: %s is us. Returning\n", name); cah->name = NULL; send_get_auth_response(cah, name); return; @@ -736,6 +755,14 @@ handle_lookup(void *cls, clh->unique_id = sh_msg->id; clh->type = ntohl(sh_msg->type); + if (strlen (name) > MAX_DNS_NAME_LENGTH) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "LOOKUP: %s is too long", name); + clh->name = NULL; + send_lookup_response(clh, 0, NULL); + return; + } + if (GNUNET_YES == auto_import_pkey) { gns_resolver_lookup_record(zone_hash, clh->type, name, -- 2.25.1