diff options
Diffstat (limited to 'src/testbed/gnunet-helper-testbed.c')
-rw-r--r-- | src/testbed/gnunet-helper-testbed.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index bc7f223af..0e70645c7 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c | |||
@@ -226,14 +226,18 @@ tokenizer_cb (void *cls, void *client, | |||
226 | struct GNUNET_CONFIGURATION_Handle *cfg; | 226 | struct GNUNET_CONFIGURATION_Handle *cfg; |
227 | struct WriteContext *wc; | 227 | struct WriteContext *wc; |
228 | char *controller; | 228 | char *controller; |
229 | char *hostname; | ||
229 | char *config; | 230 | char *config; |
230 | char *xconfig; | 231 | char *xconfig; |
231 | size_t config_size; | 232 | size_t config_size; |
232 | uLongf ul_config_size; | 233 | uLongf ul_config_size; |
233 | size_t xconfig_size; | 234 | size_t xconfig_size; |
234 | uint16_t cname_size; | 235 | uint16_t cname_size; |
235 | 236 | uint16_t hostname_size; | |
236 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) || | 237 | uint16_t msize; |
238 | |||
239 | msize = ntohs (message->size); | ||
240 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) || | ||
237 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) | 241 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) |
238 | { | 242 | { |
239 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 243 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
@@ -248,6 +252,14 @@ tokenizer_cb (void *cls, void *client, | |||
248 | "Controller name cannot be empty -- exiting\n"); | 252 | "Controller name cannot be empty -- exiting\n"); |
249 | goto error; | 253 | goto error; |
250 | } | 254 | } |
255 | hostname_size = ntohs (msg->hostname_size); | ||
256 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) + cname_size + 1 + | ||
257 | hostname_size) >= msize) | ||
258 | { | ||
259 | GNUNET_break (0); | ||
260 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | ||
261 | goto error; | ||
262 | } | ||
251 | ul_config_size = (uLongf) ntohs (msg->config_size); | 263 | ul_config_size = (uLongf) ntohs (msg->config_size); |
252 | config = GNUNET_malloc (ul_config_size); | 264 | config = GNUNET_malloc (ul_config_size); |
253 | xconfig_size = | 265 | xconfig_size = |
@@ -255,7 +267,7 @@ tokenizer_cb (void *cls, void *client, | |||
255 | sizeof (struct GNUNET_TESTBED_HelperInit)); | 267 | sizeof (struct GNUNET_TESTBED_HelperInit)); |
256 | if (Z_OK != | 268 | if (Z_OK != |
257 | uncompress ((Bytef *) config, &ul_config_size, | 269 | uncompress ((Bytef *) config, &ul_config_size, |
258 | (const Bytef *) (controller + cname_size + 1), | 270 | (const Bytef *) (controller + cname_size + 1 + hostname_size), |
259 | (uLongf) xconfig_size)) | 271 | (uLongf) xconfig_size)) |
260 | { | 272 | { |
261 | LOG (GNUNET_ERROR_TYPE_WARNING, | 273 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -273,7 +285,17 @@ tokenizer_cb (void *cls, void *client, | |||
273 | goto error; | 285 | goto error; |
274 | } | 286 | } |
275 | GNUNET_free (config); | 287 | GNUNET_free (config); |
276 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller); | 288 | hostname = NULL; |
289 | if (0 != hostname_size) | ||
290 | { | ||
291 | hostname = GNUNET_malloc (hostname_size + 1); | ||
292 | (void) strncpy (hostname, ((char *) &msg[1]) + cname_size + 1, hostname_size); | ||
293 | hostname[hostname_size] = '\0'; | ||
294 | } | ||
295 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller, | ||
296 | hostname); | ||
297 | GNUNET_free_non_null (hostname); | ||
298 | hostname = NULL; | ||
277 | GNUNET_assert (NULL != test_system); | 299 | GNUNET_assert (NULL != test_system); |
278 | GNUNET_assert (GNUNET_OK == | 300 | GNUNET_assert (GNUNET_OK == |
279 | GNUNET_TESTING_configuration_create (test_system, cfg)); | 301 | GNUNET_TESTING_configuration_create (test_system, cfg)); |