gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4952 - in GNUnet/src: applications/identity applications/s


From: gnunet
Subject: [GNUnet-SVN] r4952 - in GNUnet/src: applications/identity applications/session include server
Date: Fri, 8 Jun 2007 12:55:24 -0600 (MDT)

Author: grothoff
Date: 2007-06-08 12:55:23 -0600 (Fri, 08 Jun 2007)
New Revision: 4952

Modified:
   GNUnet/src/applications/identity/identity.c
   GNUnet/src/applications/session/connect.c
   GNUnet/src/include/platform.h
   GNUnet/src/server/connection.c
   GNUnet/src/server/handler.c
Log:
more checks

Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-06-08 18:40:34 UTC (rev 
4951)
+++ GNUnet/src/applications/identity/identity.c 2007-06-08 18:55:23 UTC (rev 
4952)
@@ -1260,8 +1260,10 @@
   hello = identity2Hello(identity,
                         protocol,
                         YES);
-  if (hello == NULL)
+  if (hello == NULL) {
+    GE_BREAK(NULL, 0); /* odd */
     return OK;
+  }
   transport = coreAPI->requestService("transport");
   address = transport->helloToString(hello,
                                     YES);
@@ -1270,7 +1272,7 @@
     address = STRDUP("");
   if (strlen(address)+1 >= MAX_BUFFER_SIZE - 
sizeof(CS_identity_peer_info_MESSAGE) ) {
     FREE(address);
-    address = STRDUP("invalid");
+    address = STRDUP(_("invalid"));
   }
   if (OK != coreAPI->queryPeerStatus(identity,
                                     &bpm,

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2007-06-08 18:40:34 UTC (rev 
4951)
+++ GNUnet/src/applications/session/connect.c   2007-06-08 18:55:23 UTC (rev 
4952)
@@ -536,8 +536,15 @@
                           ntohs(skey->header.size));
   }
   FREE(skey);
-  coreAPI->offerTSessionFor(receiver,
-                           tsession);
+  if (0 != memcmp(receiver,
+                 &tsession->peer,
+                 sizeof(PeerIdentity))) {
+    GE_BREAK(NULL, 0);
+    transport->disconnect(tsession);
+  } else {
+    coreAPI->offerTSessionFor(receiver,
+                             tsession);
+  }
   coreAPI->assignSessionKey(&sk,
                            receiver,
                            age,

Modified: GNUnet/src/include/platform.h
===================================================================
--- GNUnet/src/include/platform.h       2007-06-08 18:40:34 UTC (rev 4951)
+++ GNUnet/src/include/platform.h       2007-06-08 18:55:23 UTC (rev 4952)
@@ -204,7 +204,7 @@
 #endif
 
 #if defined(__sparc__)
-#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove(&__tmp, 
&(val), sizeof((val))); __tmp; })
+#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memcpy(&__tmp, &(val), 
sizeof((val))); __tmp; })
 #else
 #define MAKE_UNALIGNED(val) val
 #endif

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2007-06-08 18:40:34 UTC (rev 4951)
+++ GNUnet/src/server/connection.c      2007-06-08 18:55:23 UTC (rev 4952)
@@ -1387,7 +1387,7 @@
   for (i = 0; i < be->sendBufferSize; i++) {
     entry = be->sendBuffer[i];
     GE_ASSERT(ectx, entry != NULL);
-    if(entry->knapsackSolution == YES) {
+    if (entry->knapsackSolution == YES) {
       GE_ASSERT(ectx, entry->callback == NULL);
       FREENONNULL(entry->closure);
       FREE(entry);
@@ -1742,7 +1742,7 @@
       j = sizeof(P2P_PACKET_HEADER);
       while (j < p) {
         MESSAGE_HEADER * part = (MESSAGE_HEADER *) &plaintextMsg[j];
-        unsigned short plen = htons(MAKE_UNALIGNED(part->size));
+        unsigned short plen = ntohs(MAKE_UNALIGNED(part->size));
         if (plen < sizeof(MESSAGE_HEADER)) {
           GE_BREAK(ectx, 0);
           break;
@@ -1910,8 +1910,9 @@
  * @param hostId for which peer should we get/create a connection
  * @return the table entry for the host
  */
-static BufferEntry *addHost(const PeerIdentity * hostId,
-                           int establishSession) {
+static BufferEntry *
+addHost(const PeerIdentity * hostId,
+       int establishSession) {
   BufferEntry *root;
   BufferEntry *prev;
   unsigned int index;
@@ -1973,13 +1974,13 @@
                                void *arg) {
   unsigned int i;
   int count = 0;
-  BufferEntry *be;
+  BufferEntry * be;
 
   for(i=0;i<CONNECTION_MAX_HOSTS_;i++) {
     be = CONNECTION_buffer_[i];
     while (be != NULL) {
-      if(be->status == STAT_UP) {
-        if(method != NULL)
+      if (be->status == STAT_UP) {
+        if (method != NULL)
           method(be, arg);
         count++;
       }

Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-06-08 18:40:34 UTC (rev 4951)
+++ GNUnet/src/server/handler.c 2007-06-08 18:55:23 UTC (rev 4952)
@@ -505,6 +505,14 @@
           (char*)&enc);
     return;
   }
+  if ( (tsession != NULL) &&
+       (sender != NULL) &&
+       (0 != memcmp(sender,
+                   &tsession->peer,
+                   sizeof(PeerIdentity))) ) {
+    GE_BREAK(NULL, 0);
+    return;
+  }
   ret = checkHeader(sender,
                    (P2P_PACKET_HEADER*) msg,
                    size);
@@ -576,6 +584,16 @@
     FREE(mp);
     return;
   }
+  if ( (mp->tsession != NULL) &&
+       (0 != memcmp(&mp->sender,
+                   &mp->tsession->peer,
+                   sizeof(PeerIdentity))) ) {
+    GE_BREAK(NULL, 0);
+    FREE(mp->msg);
+    FREE(mp);
+    return;
+  }
+
   /* acquire buffer */
   if (SYSERR == transport->associate(mp->tsession))
     mp->tsession = NULL;





reply via email to

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