aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-25 21:08:55 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-25 21:08:55 +0000
commit537903a8dc4c3ecf2dfa382af0289ddf890adfc7 (patch)
tree93e448c15c843861bd5dfe86c7cad3245abedfe7 /src/hostlist
parent2b61888a0bf1d41b2b25256ca9834c3040551ce9 (diff)
downloadgnunet-537903a8dc4c3ecf2dfa382af0289ddf890adfc7.tar.gz
gnunet-537903a8dc4c3ecf2dfa382af0289ddf890adfc7.zip
fixing common off-by-one error with respect to maximum message size
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/hostlist-client.c4
-rw-r--r--src/hostlist/hostlist-server.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index ff8ab2e9a..b6514984d 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -272,7 +272,7 @@ callback_download (void *ptr,
272 size_t nmemb, 272 size_t nmemb,
273 void *ctx) 273 void *ctx)
274{ 274{
275 static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE]; 275 static char download_buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
276 const char * cbuf = ptr; 276 const char * cbuf = ptr;
277 const struct GNUNET_MessageHeader *msg; 277 const struct GNUNET_MessageHeader *msg;
278 size_t total; 278 size_t total;
@@ -295,7 +295,7 @@ callback_download (void *ptr,
295 while ( (left > 0) || 295 while ( (left > 0) ||
296 (download_pos > 0) ) 296 (download_pos > 0) )
297 { 297 {
298 cpy = GNUNET_MIN (left, GNUNET_SERVER_MAX_MESSAGE_SIZE - download_pos); 298 cpy = GNUNET_MIN (left, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - download_pos);
299 memcpy (&download_buffer[download_pos], 299 memcpy (&download_buffer[download_pos],
300 cbuf, 300 cbuf,
301 cpy); 301 cpy);
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index 0726bf3e0..014c0f41f 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -399,7 +399,7 @@ connect_handler (void *cls,
399 if (hostlist_uri == NULL) 399 if (hostlist_uri == NULL)
400 return; 400 return;
401 size = strlen (hostlist_uri) + 1; 401 size = strlen (hostlist_uri) + 1;
402 if (size + sizeof (struct GNUNET_MessageHeader) > GNUNET_SERVER_MAX_MESSAGE_SIZE) 402 if (size + sizeof (struct GNUNET_MessageHeader) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
403 { 403 {
404 GNUNET_break (0); 404 GNUNET_break (0);
405 return; 405 return;