bytes_wrote =
GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos,
wc->length - wc->pos);
- GNUNET_assert (GNUNET_SYSERR != bytes_wrote);
+ if (GNUNET_SYSERR == bytes_wrote)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Cannot reply back configuration\n");
+ GNUNET_free (wc->data);
+ GNUNET_free (wc);
+ return;
+ }
wc->pos += bytes_wrote;
if (wc->pos == wc->length)
{
struct GNUNET_TESTBED_HelperReply *reply;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct WriteContext *wc;
+ char *binary;
char *controller;
+ char *hostname;
char *config;
char *xconfig;
size_t config_size;
uLongf ul_config_size;
size_t xconfig_size;
uint16_t cname_size;
-
- if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) ||
+ uint16_t hostname_size;
+ uint16_t msize;
+
+ msize = ntohs (message->size);
+ if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) ||
(GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type)))
{
LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n");
"Controller name cannot be empty -- exiting\n");
goto error;
}
+ hostname_size = ntohs (msg->hostname_size);
+ if ((sizeof (struct GNUNET_TESTBED_HelperInit) + cname_size + 1 +
+ hostname_size) >= msize)
+ {
+ GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n");
+ goto error;
+ }
ul_config_size = (uLongf) ntohs (msg->config_size);
config = GNUNET_malloc (ul_config_size);
xconfig_size =
sizeof (struct GNUNET_TESTBED_HelperInit));
if (Z_OK !=
uncompress ((Bytef *) config, &ul_config_size,
- (const Bytef *) (controller + cname_size + 1),
+ (const Bytef *) (controller + cname_size + 1 + hostname_size),
(uLongf) xconfig_size))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
goto error;
}
GNUNET_free (config);
- test_system = GNUNET_TESTING_system_create ("testbed-helper", controller);
+ hostname = NULL;
+ if (0 != hostname_size)
+ {
+ hostname = GNUNET_malloc (hostname_size + 1);
+ (void) strncpy (hostname, ((char *) &msg[1]) + cname_size + 1, hostname_size);
+ hostname[hostname_size] = '\0';
+ }
+ test_system = GNUNET_TESTING_system_create ("testbed-helper", controller,
+ hostname);
+ GNUNET_free_non_null (hostname);
+ hostname = NULL;
GNUNET_assert (NULL != test_system);
GNUNET_assert (GNUNET_OK ==
GNUNET_TESTING_configuration_create (test_system, cfg));
goto error;
}
LOG_DEBUG ("Staring testbed with config: %s\n", config);
+ binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-testbed");
testbed =
GNUNET_OS_start_process (GNUNET_YES,
GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , NULL,
- NULL, "gnunet-service-testbed",
+ NULL,
+ binary,
"gnunet-service-testbed", "-c", config, NULL);
+ GNUNET_free (binary);
GNUNET_free (config);
if (NULL == testbed)
{