[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21264 - gnunet/src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21264 - gnunet/src/peerinfo |
Date: |
Fri, 4 May 2012 13:44:58 +0200 |
Author: grothoff
Date: 2012-05-04 13:44:58 +0200 (Fri, 04 May 2012)
New Revision: 21264
Modified:
gnunet/src/peerinfo/peerinfo_api.c
Log:
-extra IPC checks
Modified: gnunet/src/peerinfo/peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api.c 2012-05-04 11:44:32 UTC (rev 21263)
+++ gnunet/src/peerinfo/peerinfo_api.c 2012-05-04 11:44:58 UTC (rev 21264)
@@ -121,6 +121,16 @@
struct GNUNET_TIME_Absolute timeout;
/**
+ * Peer we are interested in (only valid if iteration was restricted to one
peer).
+ */
+ struct GNUNET_PeerIdentity peer;
+
+ /**
+ * Is 'peer' set?
+ */
+ int have_peer;
+
+ /**
* Are we now receiving?
*/
int in_receive;
@@ -476,6 +486,7 @@
const struct InfoMessage *im;
const struct GNUNET_HELLO_Message *hello;
GNUNET_PEERINFO_Processor cb;
+ struct GNUNET_PeerIdentity id;
void *cb_cls;
uint16_t ms;
@@ -519,6 +530,18 @@
}
im = (const struct InfoMessage *) msg;
GNUNET_break (0 == ntohl (im->reserved));
+ if ( (GNUNET_YES == ic->have_peer) &&
+ (0 != memcmp (&ic->peer, &im->peer, sizeof (struct
GNUNET_PeerIdentity))) )
+ {
+ /* bogus message (from a different iteration call?); out of sequence! */
+ GNUNET_break (0);
+ GNUNET_PEERINFO_iterate_cancel (ic);
+ reconnect (h);
+ if (NULL != cb)
+ cb (cb_cls, NULL, NULL,
+ _("Received invalid message from `PEERINFO' service."));
+ return;
+ }
hello = NULL;
if (ms > sizeof (struct InfoMessage) + sizeof (struct GNUNET_MessageHeader))
{
@@ -534,7 +557,30 @@
_("Received invalid message from `PEERINFO' service."));
return;
}
+ if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &id))
+ {
+ /* malformed message */
+ GNUNET_break (0);
+ GNUNET_PEERINFO_iterate_cancel (ic);
+ reconnect (h);
+ if (NULL != cb)
+ cb (cb_cls, NULL, NULL,
+ _("Received invalid message from `PEERINFO' service."));
+ return;
+ }
+ if (0 != memcmp (&im->peer, &id, sizeof (struct GNUNET_PeerIdentity)))
+ {
+ /* malformed message */
+ GNUNET_break (0);
+ GNUNET_PEERINFO_iterate_cancel (ic);
+ reconnect (h);
+ if (NULL != cb)
+ cb (cb_cls, NULL, NULL,
+ _("Received invalid message from `PEERINFO' service."));
+ return;
+ }
}
+
/* normal data message */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received %u bytes of `%s' information about peer `%s' from `%s'
service\n",
@@ -637,6 +683,7 @@
struct GNUNET_PEERINFO_IteratorContext *ic;
struct GNUNET_PEERINFO_AddContext *ac;
+ ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext));
if (NULL == peer)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -662,8 +709,9 @@
lpm->header.size = htons (sizeof (struct ListPeerMessage));
lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
+ ic->have_peer = GNUNET_YES;
+ ic->peer = *peer;
}
- ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext));
ic->h = h;
ic->ac = ac;
ic->callback = callback;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21264 - gnunet/src/peerinfo,
gnunet <=