gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35290 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r35290 - gnunet/src/util
Date: Sat, 21 Feb 2015 13:41:11 +0100

Author: grothoff
Date: 2015-02-21 13:41:11 +0100 (Sat, 21 Feb 2015)
New Revision: 35290

Modified:
   gnunet/src/util/network.c
Log:
be more careful with errno, so we can be sure it is not overwritten by 'free()' 
and the like

Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c   2015-02-21 12:38:19 UTC (rev 35289)
+++ gnunet/src/util/network.c   2015-02-21 12:41:11 UTC (rev 35290)
@@ -315,6 +315,8 @@
                           int af,
                            int type)
 {
+  int eno;
+
   h->af = af;
   h->type = type;
   if (h->fd == INVALID_SOCKET)
@@ -322,7 +324,9 @@
 #ifdef MINGW
     SetErrnoFromWinsockError (WSAGetLastError ());
 #endif
+    eno = errno;
     GNUNET_free (h);
+    errno = eno;
     return GNUNET_SYSERR;
   }
 #ifndef MINGW
@@ -339,8 +343,10 @@
 
   if (GNUNET_SYSERR == GNUNET_NETWORK_socket_set_blocking (h, GNUNET_NO))
   {
+    eno = errno;
     GNUNET_break (0);
     GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (h));
+    errno = eno;
     return GNUNET_SYSERR;
   }
 #ifdef DARWIN
@@ -370,6 +376,7 @@
                              socklen_t *address_len)
 {
   struct GNUNET_NETWORK_Handle *ret;
+  int eno;
 
   ret = GNUNET_new (struct GNUNET_NETWORK_Handle);
 #if DEBUG_NETWORK
@@ -381,7 +388,7 @@
                            (struct sockaddr *) &name,
                            &namelen);
 
-    if (gsn == 0)
+    if (0 == gsn)
       LOG (GNUNET_ERROR_TYPE_DEBUG,
           "Accepting connection on `%s'\n",
            GNUNET_a2s ((const struct sockaddr *) &name,
@@ -393,14 +400,19 @@
                     address_len);
   if (-1 == ret->fd)
   {
+    eno = errno;
     GNUNET_free (ret);
+    errno = eno;
     return NULL;
   }
   if (GNUNET_OK !=
       initialize_network_handle (ret,
                                  (NULL != address) ? address->sa_family : 
desc->af,
                                  SOCK_STREAM))
+  {
+
     return NULL;
+  }
   return ret;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]