aboutsummaryrefslogtreecommitdiff
path: root/src/util/server_mst.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-07-02 16:41:31 +0000
committerNathan S. Evans <evans@in.tum.de>2010-07-02 16:41:31 +0000
commit4238e624cf345537e26c0111418dcd53bc5c1a97 (patch)
tree0665f48539d6754881496979de77fbb7c5c507b2 /src/util/server_mst.c
parent5f3520842f7f9fa3b35d7afd96b4b963cc0fcd91 (diff)
downloadgnunet-4238e624cf345537e26c0111418dcd53bc5c1a97.tar.gz
gnunet-4238e624cf345537e26c0111418dcd53bc5c1a97.zip
thought realloc was problem, but not properly freeing memory. believe that transport segfault *could* be related to growing connection buffers on demand... appreciate another look if someone has the time (Christian...)
Diffstat (limited to 'src/util/server_mst.c')
-rw-r--r--src/util/server_mst.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/util/server_mst.c b/src/util/server_mst.c
index 505d98998..5a152be28 100644
--- a/src/util/server_mst.c
+++ b/src/util/server_mst.c
@@ -129,6 +129,10 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
129 size_t delta; 129 size_t delta;
130 uint16_t want; 130 uint16_t want;
131 char *ibuf; 131 char *ibuf;
132
133#if !REALLOC
134 char *temp_buf;
135#endif
132 int need_align; 136 int need_align;
133 unsigned long offset; 137 unsigned long offset;
134 int ret; 138 int ret;
@@ -142,11 +146,17 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
142#endif 146#endif
143 if ((size > mst->curr_buf) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE)) /* Received bigger message than we can currently handle! */ 147 if ((size > mst->curr_buf) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE)) /* Received bigger message than we can currently handle! */
144 { 148 {
145 newsize = mst->curr_buf + size; /* How much space do we need? */ 149 newsize = mst->curr_buf + size + 1; /* How much space do we need? */
146 if (newsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 150 if (newsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
147 newsize = GNUNET_SERVER_MAX_MESSAGE_SIZE; /* Check it's not bigger than GNUNET_SERVER_MAX_MESSAGE_SIZE */ 151 newsize = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1; /* Check it's not bigger than GNUNET_SERVER_MAX_MESSAGE_SIZE */
148 152#if REALLOC
149 mst->hdr = GNUNET_realloc(mst->hdr, newsize); 153 mst->hdr = GNUNET_realloc(mst->hdr, newsize);
154#else
155 temp_buf = GNUNET_malloc(newsize);
156 memcpy(temp_buf, mst->hdr, mst->curr_buf);
157 GNUNET_free(mst->hdr);
158 mst->hdr = temp_buf;
159#endif
150 mst->curr_buf = newsize; 160 mst->curr_buf = newsize;
151 } 161 }
152 162
@@ -303,6 +313,7 @@ GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
303void 313void
304GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst) 314GNUNET_SERVER_mst_destroy (struct GNUNET_SERVER_MessageStreamTokenizer *mst)
305{ 315{
316 GNUNET_free (mst->hdr);
306 GNUNET_free (mst); 317 GNUNET_free (mst);
307} 318}
308 319