From 537903a8dc4c3ecf2dfa382af0289ddf890adfc7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 25 Jun 2010 21:08:55 +0000 Subject: fixing common off-by-one error with respect to maximum message size --- src/fs/fs_publish.c | 2 +- src/fs/gnunet-service-fs_indexing.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/fs') diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 2ebb96169..13701405e 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -761,7 +761,7 @@ hash_for_index_cb (void *cls, fn = GNUNET_STRINGS_filename_expand (p->filename); GNUNET_assert (fn != NULL); slen = strlen (fn) + 1; - if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage)) + if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Can not index file `%s': %s. Will try to insert instead.\n"), diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index d6654bcdc..b72c53fc0 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -430,7 +430,7 @@ GNUNET_FS_handle_index_list_get (void *cls, { struct GNUNET_SERVER_TransmitContext *tc; struct IndexInfoMessage *iim; - char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; + char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; size_t slen; const char *fn; struct IndexInfo *pos; @@ -442,8 +442,7 @@ GNUNET_FS_handle_index_list_get (void *cls, { fn = pos->filename; slen = strlen (fn) + 1; - if (slen + sizeof (struct IndexInfoMessage) > - GNUNET_SERVER_MAX_MESSAGE_SIZE) + if (slen + sizeof (struct IndexInfoMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); break; -- cgit v1.2.3