fix div by zero
[oweals/gnunet.git] / src / transport / plugin_transport_tcp.c
index a63013caad6e644451869318074b6eeeb0130197..75a8855354d9dc207ee43f2238bcdec9c42a087a 100644 (file)
@@ -2,20 +2,18 @@
   This file is part of GNUnet
   Copyright (C) 2002--2015 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
-  by the Free Software Foundation; either version 3, or (at your
-  option) any later version.
+  GNUnet is free software: you can redistribute it and/or modify it
+  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.
 
   GNUnet is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with GNUnet; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
+  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/>.
  */
 /**
  * @file transport/plugin_transport_tcp.c
@@ -3172,8 +3170,6 @@ handle_tcp_welcome (void *cls,
                    sizeof(struct GNUNET_PeerIdentity)))
   {
     /* refuse connections from ourselves */
-    GNUNET_SERVER_receive_done (client,
-                                GNUNET_SYSERR);
     if (GNUNET_OK ==
         GNUNET_SERVER_client_get_address (client,
                                           &vaddr,
@@ -3185,6 +3181,8 @@ handle_tcp_welcome (void *cls,
            GNUNET_a2s (vaddr, alen));
       GNUNET_free (vaddr);
     }
+    GNUNET_SERVER_receive_done (client,
+                                GNUNET_SYSERR);
     return;
   }
 
@@ -3348,12 +3346,13 @@ handle_tcp_data (void *cls,
   if (NULL == session)
   {
     /* No inbound session found */
-    void *vaddr;
+    void *vaddr = NULL;
     size_t alen;
 
-    GNUNET_SERVER_client_get_address (client,
-                                      &vaddr,
-                                      &alen);
+    GNUNET_assert (GNUNET_OK ==
+                  GNUNET_SERVER_client_get_address (client,
+                                                    &vaddr,
+                                                    &alen));
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Received unexpected %u bytes of type %u from `%s'\n",
          (unsigned int) ntohs (message->size),
@@ -3369,7 +3368,7 @@ handle_tcp_data (void *cls,
   if (GNUNET_YES == session->expecting_welcome)
   {
     /* Session is expecting WELCOME message */
-    void *vaddr;
+    void *vaddr = NULL;
     size_t alen;
 
     GNUNET_SERVER_client_get_address (client,
@@ -3389,7 +3388,7 @@ handle_tcp_data (void *cls,
 
   session->last_activity = GNUNET_TIME_absolute_get ();
   {
-    void *vaddr;
+    void *vaddr = NULL;
     size_t alen;
 
     GNUNET_SERVER_client_get_address (client,