REST: nothing triggers rest
[oweals/gnunet.git] / src / gns / gnunet-service-gns.c
index f8f0683014d7872e8d8ac791a319124e2d5dc30c..65c232f9374213d2ba73553d7461a140f78c3496 100644 (file)
@@ -3,7 +3,7 @@
      Copyright (C) 2011-2018 GNUnet e.V.
 
      GNUnet is free software: you can redistribute it and/or modify it
-     under the terms of the GNU General Public License as published
+     under the terms of the GNU Affero General Public License as published
      by the Free Software Foundation, either version 3 of the License,
      or (at your option) any later version.
 
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
+
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 /**
  * @file gns/gnunet-service-gns.c
@@ -393,19 +398,12 @@ static int
 check_lookup (void *cls,
               const struct LookupMessage *l_msg)
 {
-  size_t msg_size;
-  const char* name;
+  size_t nlen;
 
   (void) cls;
-  msg_size = ntohs (l_msg->header.size);
-  if (msg_size < sizeof (struct LookupMessage))
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  name = (const char *) &l_msg[1];
-  if ( ('\0' != name[msg_size - sizeof (struct LookupMessage) - 1]) ||
-       (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) )
+  GNUNET_MQ_check_zero_termination (l_msg);
+  nlen = ntohs (l_msg->header.size) - sizeof (struct LookupMessage);
+  if (nlen > GNUNET_DNSPARSER_MAX_NAME_LENGTH)
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;