From 9dac7b6b7b035d55bdb9731795712ead92e11f76 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 7 Sep 2009 11:58:04 +0000 Subject: fixes --- src/peerinfo/gnunet-service-peerinfo.c | 23 ++++++++++++++++++----- src/peerinfo/peerinfo_api.c | 3 +-- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src/peerinfo') diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 3a6030fda..281779897 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -206,11 +206,24 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) { size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer)); hello = (const struct GNUNET_HELLO_Message *) buffer; - now = GNUNET_TIME_absolute_get (); - hello_clean = GNUNET_HELLO_iterate_addresses (hello, - GNUNET_YES, - &discard_expired, &now); - entry->hello = hello_clean; + if ( (size < sizeof (struct GNUNET_MessageHeader)) || + (size != ntohs((((const struct GNUNET_MessageHeader*) hello)->size))) || + (size != GNUNET_HELLO_size (hello)) ) + { + GNUNET_break (0); + if (0 != UNLINK (fn)) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, + "unlink", + fn); + } + else + { + now = GNUNET_TIME_absolute_get (); + hello_clean = GNUNET_HELLO_iterate_addresses (hello, + GNUNET_YES, + &discard_expired, &now); + entry->hello = hello_clean; + } } GNUNET_free (fn); entry->next = hosts; diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 28865edc6..57197798b 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -262,8 +262,8 @@ GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_CLIENT_Connection *client; struct ListAllPeersMessage *lapm; struct ListPeerMessage *lpm; - size_t hs; struct InfoContext *ihc; + size_t hs; client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); if (client == NULL) @@ -279,7 +279,6 @@ GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg, ihc->callback = callback; ihc->callback_cls = callback_cls; ihc->timeout = GNUNET_TIME_relative_to_absolute (timeout); - hs = 0; if (peer == NULL) { lapm = (struct ListAllPeersMessage *) &ihc[1]; -- cgit v1.2.3